Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the hostname and the port number? #251

Open
szabgab opened this issue Dec 13, 2023 · 1 comment
Open

How to get the hostname and the port number? #251

szabgab opened this issue Dec 13, 2023 · 1 comment

Comments

@szabgab
Copy link

szabgab commented Dec 13, 2023

Given a request like this: http://localhost:5000/echo?text=Hello%20World how can I get the hostname and the port number?

As far as I can see this information is (only) available in the request.header() in a Header called Host.
The server has the server.server_addr() that would return them in like this: 127.0.0.1:5000.

IMHO it would be useful for both the server and the request to have method: host and port.

@bradfier
Copy link
Member

server_addr() is more complicated than that. It returns you a ListenAddr which may be a TCP socket or a Unix path, and it's up to you to decide how to handle those cases for your application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants