Skip to content

Commit

Permalink
net: document that Header.Get key is case insensitive
Browse files Browse the repository at this point in the history
Document that key in Header.Get(key) is case insensitive in
http.Header, mail.Header, textproto.Header.

Fixes golang#18019

Change-Id: Iba7932491e02e555190b6fce053088b580a853ef
Reviewed-on: https://go-review.googlesource.com/33530
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
kavirajk authored and bradfitz committed Nov 28, 2016
1 parent beec631 commit e2d5e54
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/net/http/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ func (h Header) Set(key, value string) {
}

// 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, access the map directly
// with CanonicalHeaderKey.
// 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)
}
Expand Down
4 changes: 4 additions & 0 deletions src/net/mail/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ func ParseDate(date string) (time.Time, error) {
type Header map[string][]string

// Get gets the first value associated with the given key.
// It is case insensitive; 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.
func (h Header) Get(key string) string {
return textproto.MIMEHeader(h).Get(key)
}
Expand Down
4 changes: 3 additions & 1 deletion src/net/textproto/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ func (h MIMEHeader) Set(key, value string) {
}

// Get gets the first value associated with the given key.
// It is case insensitive; CanonicalMIMEHeaderKey is used
// to canonicalize the provided key.
// If there are no values associated with the key, Get returns "".
// Get is a convenience method. For more complex queries,
// To access multiple values of a key, or to use non-canonical keys,
// access the map directly.
func (h MIMEHeader) Get(key string) string {
if h == nil {
Expand Down

0 comments on commit e2d5e54

Please sign in to comment.