]> Cypherpunks repositories - gostls13.git/commitdiff
net: document that Header.Get key is case insensitive
authorKaviraj <kavirajkanagaraj@gmail.com>
Wed, 23 Nov 2016 13:33:46 +0000 (19:03 +0530)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 28 Nov 2016 18:37:05 +0000 (18:37 +0000)
Document that key in Header.Get(key) is case insensitive in
http.Header, mail.Header, textproto.Header.

Fixes #18019

Change-Id: Iba7932491e02e555190b6fce053088b580a853ef
Reviewed-on: https://go-review.googlesource.com/33530
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/header.go
src/net/mail/message.go
src/net/textproto/header.go

index 6343165a840c7ab120c78bfd5cb4bad7bd73360e..832169247fed7ced1de930938cfa620265925abb 100644 (file)
@@ -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)
 }
index aa3a3e78c4ef4905ce8c0b1162a3849fcfa89ca8..702b765c3491b753cb37c6c37c2e19a7eb118ef9 100644 (file)
@@ -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)
 }
index 2e2752a755899c7e6c5d2b30e68c9b619bbda767..ed096d9a3cb4ddd404e8d7acd0691b93ba3ec159 100644 (file)
@@ -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 {