Documentation
¶
Overview ¶
Package header provides functions for parsing HTTP headers.
Index ¶
- func Copy(header http.Header) http.Header
- func Negotiate(hk string, h http.Header, offers []string, defaultOffer string) string
- func ParseList(header http.Header, key string) []string
- func ParseTime(header http.Header, key string) time.Time
- func ParseValueAndParams(header http.Header, key string) (value string, params map[string]string)
- type AcceptSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Negotiate ¶
Negotiate returns the best offered content type for the request's Accept header. If two offers match with equal weight, then the more specific offer is preferred. For example, text/* trumps */*. If two offers match with equal weight and specificity, then the offer earlier in the list is preferred. If no offers match, then defaultOffer is returned.
func ParseList ¶
ParseList parses a comma separated list of values. Commas are ignored in quoted strings. Quoted values are not unescaped or unquoted. Whitespace is trimmed.
func ParseTime ¶
ParseTime parses the header as time. The zero value is returned if the header is not present or there is an error parsing the header.
func ParseValueAndParams ¶
ParseValueAndParams parses a comma separated list of values with optional semicolon separated name-value pairs. Content-Type and Content-Disposition headers are in this format.
Types ¶
type AcceptSpec ¶
AcceptSpec describes an Accept* header.