diff options
author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-02-04 19:40:38 +0000 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-02-05 01:25:38 +0000 |
commit | 107a6ef41f3518aba8d791cdb11bb5e63a2e16b9 (patch) | |
tree | 43a4abe0bbfa09eeb98060dfa95772ec051ddf15 | |
parent | 4d02b1241738a5bd06201455a4f74a013f6c9437 (diff) | |
download | go-107a6ef41f3518aba8d791cdb11bb5e63a2e16b9.tar.gz go-107a6ef41f3518aba8d791cdb11bb5e63a2e16b9.zip |
net/http: document Request.Header and Request.Close more
Updates #14227
Change-Id: If39f11471ecd307c9483f64e73f9c89fe906ae71
Reviewed-on: https://go-review.googlesource.com/19222
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
-rw-r--r-- | src/net/http/request.go | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/net/http/request.go b/src/net/http/request.go index 16c5bb43ac..03f3e2b974 100644 --- a/src/net/http/request.go +++ b/src/net/http/request.go @@ -99,30 +99,37 @@ type Request struct { ProtoMajor int // 1 ProtoMinor int // 0 - // A header maps request lines to their values. - // If the header says + // Header contains the request header fields either received + // by the server or to be sent by the client. // + // If a server received a request with header lines, + // + // Host: example.com // accept-encoding: gzip, deflate // Accept-Language: en-us - // Connection: keep-alive + // fOO: Bar + // foo: two // // then // // Header = map[string][]string{ // "Accept-Encoding": {"gzip, deflate"}, // "Accept-Language": {"en-us"}, - // "Connection": {"keep-alive"}, + // "Foo": {"Bar", "two"}, // } // - // HTTP defines that header names are case-insensitive. - // The request parser implements this by canonicalizing the - // name, making the first character and any characters - // following a hyphen uppercase and the rest lowercase. + // For incoming requests, the Host header is promoted to the + // Request.Host field and removed from the Header map. // - // For client requests certain headers are automatically - // added and may override values in Header. + // HTTP defines that header names are case-insensitive. The + // request parser implements this by using CanonicalHeaderKey, + // making the first character and any characters following a + // hyphen uppercase and the rest lowercase. // - // See the documentation for the Request.Write method. + // For client requests, certain headers such as Content-Length + // and Connection are automatically written when needed and + // values in Header may be ignored. See the documentation + // for the Request.Write method. Header Header // Body is the request's body. @@ -152,8 +159,15 @@ type Request struct { TransferEncoding []string // Close indicates whether to close the connection after - // replying to this request (for servers) or after sending - // the request (for clients). + // replying to this request (for servers) or after sending this + // request and reading its response (for clients). + // + // For server requests, the HTTP server handles this automatically + // and this field is not needed by Handlers. + // + // The client requests, setting this field prevents re-use of + // TCP connections between requests to the same hosts, as if + // Transport.DisableKeepAlives were set. Close bool // For server requests Host specifies the host on which the |