net/http: document CanonicalHeaderKey from Header

And remove some unnecessary textproto references. (The net/http
package's CanonicalHeaderKey just calls textproto's
CanonicalMIMEHeaderKey)

Fixes #28894

Change-Id: Ibd277893a168368c593147a2677ad6130870cb88
Reviewed-on: https://go-review.googlesource.com/c/152157
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Brad Fitzpatrick 2018-12-03 17:01:18 +00:00
parent cef41e0d4b
commit f98081e515
1 changed files with 5 additions and 2 deletions

View File

@ -15,12 +15,15 @@ import (
) )
// A Header represents the key-value pairs in an HTTP header. // A Header represents the key-value pairs in an HTTP header.
//
// The keys should be in canonical form, as returned by
// CanonicalHeaderKey.
type Header map[string][]string type Header map[string][]string
// Add adds the key, value pair to the header. // Add adds the key, value pair to the header.
// It appends to any existing values associated with key. // It appends to any existing values associated with key.
// The key is case insensitive; it is canonicalized by // The key is case insensitive; it is canonicalized by
// textproto.CanonicalMIMEHeaderKey. // CanonicalHeaderKey.
func (h Header) Add(key, value string) { func (h Header) Add(key, value string) {
textproto.MIMEHeader(h).Add(key, value) textproto.MIMEHeader(h).Add(key, value)
} }
@ -61,7 +64,7 @@ func (h Header) has(key string) bool {
// Del deletes the values associated with key. // Del deletes the values associated with key.
// The key is case insensitive; it is canonicalized by // The key is case insensitive; it is canonicalized by
// textproto.CanonicalMIMEHeaderKey. // CanonicalHeaderKey.
func (h Header) Del(key string) { func (h Header) Del(key string) {
textproto.MIMEHeader(h).Del(key) textproto.MIMEHeader(h).Del(key)
} }