Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrLength = errors.New("encoding/hex: odd length hex string")
ErrLength reports an attempt to decode an odd-length input using Decode or [DecodeString]. The stream-based Decoder returns io.ErrUnexpectedEOF instead of ErrLength.
Functions ¶
func CanonicalMIMEHeaderKey ¶
CanonicalMIMEHeaderKey returns the canonical format of the MIME header key s. The canonicalization converts the first letter and any letter following a hyphen to upper case; the rest are converted to lowercase. For example, the canonical key for "accept-encoding" is "Accept-Encoding". MIME header keys are assumed to be ASCII only. If s contains a space or invalid header field bytes, it is returned without modifications.
func Decode ¶
Decode decodes src into DecodedLen(len(src)) bytes, returning the actual number of bytes written to dst.
Decode expects that src contains only hexadecimal characters and that src has even length. If the input is malformed, Decode returns the number of bytes decoded before the error.
func DecodedLen ¶
DecodedLen returns the length of a decoding of x source bytes. Specifically, it returns x / 2.
func Encode ¶
Encode encodes src into EncodedLen(len(src)) bytes of dst. As a convenience, it returns the number of bytes written to dst, but this value is always EncodedLen(len(src)). Encode implements hexadecimal encoding.
func EncodedLen ¶
EncodedLen returns the length of an encoding of n source bytes. Specifically, it returns n * 2.
Types ¶
type InvalidByteError ¶
type InvalidByteError byte
InvalidByteError values describe errors resulting from an invalid byte in a hex string.
func (InvalidByteError) Error ¶
func (e InvalidByteError) Error() string
type MIMEHeader ¶
A MIMEHeader represents a MIME-style header mapping keys to sets of values.
func (MIMEHeader) Add ¶
func (h MIMEHeader) Add(key, value string)
Add adds the key, value pair to the header. It appends to any existing values associated with key.
func (MIMEHeader) Del ¶
func (h MIMEHeader) Del(key string)
Del deletes the values associated with key.
func (MIMEHeader) Get ¶
func (h MIMEHeader) Get(key 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 use non-canonical keys, access the map directly.
func (MIMEHeader) Set ¶
func (h MIMEHeader) Set(key, value string)
Set sets the header entries associated with key to the single element value. It replaces any existing values associated with key.
func (MIMEHeader) Values ¶
func (h MIMEHeader) Values(key string) []string
Values returns all values associated with the given key. It is case insensitive; CanonicalMIMEHeaderKey is used to canonicalize the provided key. To use non-canonical keys, access the map directly. The returned slice is not a copy.