Documentation ¶
Overview ¶
nolint
nolint
nolint
nolint
Index ¶
- Variables
- func AppendHuffmanString(dst []byte, s string) []byte
- func HuffmanDecode(w io.Writer, v []byte) (int, error)
- func HuffmanDecodeToString(v []byte) (string, error)
- func HuffmanEncodeLength(s string) uint64
- type Decoder
- func (d *Decoder) Close() error
- func (d *Decoder) DecodeFull(p []byte) ([]HeaderField, error)
- func (d *Decoder) EmitEnabled() bool
- func (d *Decoder) SetAllowedMaxDynamicTableSize(v uint32)
- func (d *Decoder) SetEmitEnabled(v bool)
- func (d *Decoder) SetEmitFunc(emitFunc func(f HeaderField))
- func (d *Decoder) SetMaxDynamicTableSize(v uint32)
- func (d *Decoder) SetMaxStringLength(n int)
- func (d *Decoder) Write(p []byte) (n int, err error)
- type DecodingError
- type HeaderField
- type InvalidIndexError
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidHuffman = errors.New("hpack: invalid Huffman-encoded data")
ErrInvalidHuffman is returned for errors found decoding Huffman-encoded strings.
var ErrStringLength = errors.New("hpack: string too long")
ErrStringLength is returned by Decoder.Write when the max string length (as configured by Decoder.SetMaxStringLength) would be violated.
Functions ¶
func AppendHuffmanString ¶
AppendHuffmanString appends s, as encoded in Huffman codes, to dst and returns the extended buffer.
func HuffmanDecode ¶
HuffmanDecode decodes the string in v and writes the expanded result to w, returning the number of bytes written to w and the Write call's return value. At most one Write call is made.
func HuffmanDecodeToString ¶
HuffmanDecodeToString decodes the string in v.
func HuffmanEncodeLength ¶
HuffmanEncodeLength returns the number of bytes required to encode s in Huffman codes. The result is round up to byte boundary.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder is the decoding context for incremental processing of header blocks.
func NewDecoder ¶
func NewDecoder(maxDynamicTableSize uint32, emitFunc func(f HeaderField)) *Decoder
NewDecoder returns a new decoder with the provided maximum dynamic table size. The emitFunc will be called for each valid field parsed, in the same goroutine as calls to Write, before Write returns.
func (*Decoder) Close ¶
Close declares that the decoding is complete and resets the Decoder to be reused again for a new header block. If there is any remaining data in the decoder's buffer, Close returns an error.
func (*Decoder) DecodeFull ¶
func (d *Decoder) DecodeFull(p []byte) ([]HeaderField, error)
DecodeFull decodes an entire block.
TODO: remove this method and make it incremental later? This is easier for debugging now.
func (*Decoder) EmitEnabled ¶
EmitEnabled reports whether calls to the emitFunc provided to NewDecoder are currently enabled. The default is true.
func (*Decoder) SetAllowedMaxDynamicTableSize ¶
SetAllowedMaxDynamicTableSize sets the upper bound that the encoded stream (via dynamic table size updates) may set the maximum size to.
func (*Decoder) SetEmitEnabled ¶
SetEmitEnabled controls whether the emitFunc provided to NewDecoder should be called. The default is true.
This facility exists to let servers enforce MAX_HEADER_LIST_SIZE while still decoding and keeping in-sync with decoder state, but without doing unnecessary decompression or generating unnecessary garbage for header fields past the limit.
func (*Decoder) SetEmitFunc ¶
func (d *Decoder) SetEmitFunc(emitFunc func(f HeaderField))
SetEmitFunc changes the callback used when new header fields are decoded. It must be non-nil. It does not affect EmitEnabled.
func (*Decoder) SetMaxDynamicTableSize ¶
func (*Decoder) SetMaxStringLength ¶
SetMaxStringLength sets the maximum size of a HeaderField name or value string. If a string exceeds this length (even after any decompression), Write will return ErrStringLength. A value of 0 means unlimited and is the default from NewDecoder.
type DecodingError ¶
type DecodingError struct {
Err error
}
A DecodingError is something the spec defines as a decoding error.
func (DecodingError) Error ¶
func (de DecodingError) Error() string
type HeaderField ¶
type HeaderField struct {
Name, Value string
// Sensitive means that this header field should never be
// indexed.
Sensitive bool
}
A HeaderField is a name-value pair. Both the name and value are treated as opaque sequences of octets.
func (HeaderField) IsPseudo ¶
func (hf HeaderField) IsPseudo() bool
IsPseudo reports whether the header field is an http2 pseudo header. That is, it reports whether it starts with a colon. It is not otherwise guaranteed to be a valid pseudo header field, though.
func (HeaderField) Size ¶
func (hf HeaderField) Size() uint32
Size returns the size of an entry per RFC 7541 section 4.1.
func (HeaderField) String ¶
func (hf HeaderField) String() string
type InvalidIndexError ¶
type InvalidIndexError int
An InvalidIndexError is returned when an encoder references a table entry before the static table or after the end of the dynamic table.
func (InvalidIndexError) Error ¶
func (e InvalidIndexError) Error() string