1
0
mirror of https://github.com/golang/go synced 2024-10-03 08:11:27 -06:00

net/http: clarify that Request.Host may contain a port number

Fixes #4172

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6872055
This commit is contained in:
Brad Fitzpatrick 2012-12-04 07:09:01 -08:00
parent 23ca24018a
commit add1bed735
3 changed files with 12 additions and 1 deletions

View File

@ -124,6 +124,7 @@ type Request struct {
// The host on which the URL is sought. // The host on which the URL is sought.
// Per RFC 2616, this is either the value of the Host: header // Per RFC 2616, this is either the value of the Host: header
// or the host name given in the URL itself. // or the host name given in the URL itself.
// It may be of the form "host:port".
Host string Host string
// Form contains the parsed form data, including both the URL // Form contains the parsed form data, including both the URL

View File

@ -228,6 +228,16 @@ func TestReadRequestErrors(t *testing.T) {
} }
} }
func TestNewRequestHost(t *testing.T) {
req, err := NewRequest("GET", "http://localhost:1234/", nil)
if err != nil {
t.Fatal(err)
}
if req.Host != "localhost:1234" {
t.Errorf("Host = %q; want localhost:1234", req.Host)
}
}
func testMissingFile(t *testing.T, req *Request) { func testMissingFile(t *testing.T, req *Request) {
f, fh, err := req.FormFile("missing") f, fh, err := req.FormFile("missing")
if f != nil { if f != nil {

View File

@ -224,7 +224,7 @@ type URL struct {
Scheme string Scheme string
Opaque string // encoded opaque data Opaque string // encoded opaque data
User *Userinfo // username and password information User *Userinfo // username and password information
Host string Host string // host or host:port
Path string Path string
RawQuery string // encoded query values, without '?' RawQuery string // encoded query values, without '?'
Fragment string // fragment for references, without '#' Fragment string // fragment for references, without '#'