diff options
author | Muhammad Falak R Wani <falakreyaz@gmail.com> | 2018-09-30 17:54:22 +0530 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-10-02 17:07:42 +0000 |
commit | 9ec5d9c15b8dcb30d06805504477ac602f4e0385 (patch) | |
tree | d7d1bd46dd0d6b2410031d872d837e0f0407e2d7 | |
parent | 3ee9672955b163075e96d959635d1912952030e6 (diff) | |
download | go-9ec5d9c15b8dcb30d06805504477ac602f4e0385.tar.gz go-9ec5d9c15b8dcb30d06805504477ac602f4e0385.zip |
net/http: document Header.Set canonicalizes the header key
Fixes #27923
Change-Id: Ia902a1966beeae56e43265fc5ed987555fa834b6
Reviewed-on: https://go-review.googlesource.com/138677
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r-- | src/net/http/header.go | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/net/http/header.go b/src/net/http/header.go index 2aa9d6254b..d932f0900a 100644 --- a/src/net/http/header.go +++ b/src/net/http/header.go @@ -19,23 +19,27 @@ type Header map[string][]string // Add adds the key, value pair to the header. // It appends to any existing values associated with key. +// The key is case insensitive; it is canonicalized by +// textproto.CanonicalMIMEHeaderKey. func (h Header) Add(key, value string) { textproto.MIMEHeader(h).Add(key, value) } -// Set sets the header entries associated with key to -// the single element value. It replaces any existing -// values associated with key. +// Set sets the header entries associated with key to the +// single element value. It replaces any existing values +// associated with key. The key is case insensitive; it is +// canonicalized by textproto.CanonicalMIMEHeaderKey. +// To use non-canonical keys, assign to the map directly. func (h Header) Set(key, value string) { textproto.MIMEHeader(h).Set(key, value) } -// Get gets the first value associated with the given key. -// It is case insensitive; textproto.CanonicalMIMEHeaderKey is used -// to canonicalize the provided key. -// If there are no values associated with the key, Get returns "". -// To access multiple values of a key, or to use non-canonical keys, -// access the map directly. +// Get gets the first value associated with the given key. If +// there are no values associated with the key, Get returns "". +// It is case insensitive; textproto.CanonicalMIMEHeaderKey is +// used to canonicalize the provided key. To access multiple +// values of a key, or to use non-canonical keys, access the +// map directly. func (h Header) Get(key string) string { return textproto.MIMEHeader(h).Get(key) } @@ -49,6 +53,8 @@ func (h Header) get(key string) string { } // Del deletes the values associated with key. +// The key is case insensitive; it is canonicalized by +// textproto.CanonicalMIMEHeaderKey. func (h Header) Del(key string) { textproto.MIMEHeader(h).Del(key) } |