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/http: Request.Host field's definition is ambiguous #4172

Closed
adonovan opened this issue Sep 28, 2012 · 8 comments
Closed

net/http: Request.Host field's definition is ambiguous #4172

adonovan opened this issue Sep 28, 2012 · 8 comments

Comments

@adonovan
Copy link
Member

The documentation for the Host field of a net/http Request reads:

        // The host on which the URL is sought.            
        // Per RFC 2616, this is either the value of the Host: header            
        // or the host name given in the URL itself.                            
        Host string

This is somewhat ambiguous, as the Host: header may contain the :port suffix too (RFC
2616, sec 14.23), but the URL's host component definitely does not include the port
component (RFC 2396, sec 3.2.2).  So is this field supposed to be:

(a) just the host name, for vanity/virtual hosting purposes (RFC 2616, sec 5.2)?
  In this case, the docstring should read:
  // ...this is either the value of the host component of the Host: header ...
  and the implementation should parse the Host: header.

or (b) the host with optional :port, i.e. the server authority?
  In this case the docstring should read:
  // ... or the host name and optional port given in the URL itself.
  and the implementation should include the url.Port component.  The docstring should probably also include the word "authority" for bonus marks.  

Personally I think (b) is more useful.  RFC sec 14.23 defines the Host: header as the
server authority.
@rsc
Copy link
Contributor

rsc commented Oct 1, 2012

Comment 1:

I agree that we should fix the comment to say what is really going on.
I think the port is included in both cases but would have to check.

@adonovan
Copy link
Member Author

adonovan commented Oct 1, 2012

Comment 2:

You're quite right---I just realised that URL.Host is actually a host:port.
This is worth documenting too.

@adonovan
Copy link
Member Author

adonovan commented Oct 1, 2012

Comment 3:

You're quite right---I just discovered that URL.Host is actually a host:port.
This is worth documenting too.

@robpike
Copy link
Contributor

robpike commented Oct 2, 2012

Comment 4:

Labels changed: added priority-soon, documentation, removed priority-triage.

Owner changed to ---.

@rsc
Copy link
Contributor

rsc commented Oct 6, 2012

Comment 5:

Labels changed: added go1.1.

@bradfitz
Copy link
Contributor

Comment 6:

Owner changed to @bradfitz.

@bradfitz
Copy link
Contributor

bradfitz commented Dec 3, 2012

Comment 7:

https://golang.org/cl/6872055

Status changed to Started.

@bradfitz
Copy link
Contributor

bradfitz commented Dec 4, 2012

Comment 8:

This issue was closed by revision add1bed.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

5 participants