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

net/url: URL should parse the port number and store it separately #10262

Closed
foresmac opened this issue Mar 26, 2015 · 3 comments
Closed

net/url: URL should parse the port number and store it separately #10262

foresmac opened this issue Mar 26, 2015 · 3 comments

Comments

@foresmac
Copy link

The port number from a URL should not be left tacked on the end of the host when parsing a URL into a url.URL struct. Instead, the port number should be pulled out and added to a url.URL.Port field. Leaving the port in a parsed hostname invariably leaves developers calling strings.Split(url.URL.Host, ":")[0] repeatedly to get the hostname.

@foresmac
Copy link
Author

For instance:

http://www.example.com:4000/example/path?page=42

Should parse to:

url.URL{"http", "", nil, "www.example.com", 4000, "/example/path", "page=42", ""}

@minux
Copy link
Member

minux commented Mar 26, 2015

First of all, port is part of the host in RFC 2616.
And more importantly, this is a backward incompatible change, so
even if we want to add a Port field to net/url.URL, we can't.

@minux minux closed this as completed Mar 26, 2015
@mikioh mikioh changed the title net/url url.URL should parse the port number and store it separately net/url: URL should parse the port number and store it separately Mar 27, 2015
@foresmac
Copy link
Author

Fair enough.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants