package hpack
Import Path
vendor/golang.org/x/net/http2/hpack (on go.dev)
Dependency Relation
imports 5 packages, and imported by one package
Involved Source Files
encode.go
Package hpack implements HPACK, a compression format for
efficiently representing HTTP header fields in the context of HTTP/2.
See http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-09
huffman.go
static_table.go
tables.go
Package-Level Type Names (total 5)
A Decoder is the decoding context for incremental processing of
header blocks.
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.
DecodeFull decodes an entire block.
TODO: remove this method and make it incremental later? This is
easier for debugging now.
EmitEnabled reports whether calls to the emitFunc provided to NewDecoder
are currently enabled. The default is true.
SetAllowedMaxDynamicTableSize sets the upper bound that the encoded
stream (via dynamic table size updates) may set the maximum size
to.
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.
SetEmitFunc changes the callback used when new header fields
are decoded.
It must be non-nil. It does not affect EmitEnabled.
(*Decoder) SetMaxDynamicTableSize(v uint32)
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.
(*Decoder) Write(p []byte) (n int, err error)
*Decoder : internal/bisect.Writer
*Decoder : io.Closer
*Decoder : io.WriteCloser
*Decoder : io.Writer
func NewDecoder(maxDynamicTableSize uint32, emitFunc func(f HeaderField)) *Decoder
A DecodingError is something the spec defines as a decoding error.
Err error
( DecodingError) Error() string
DecodingError : error
MaxDynamicTableSize returns the current dynamic header table size.
SetMaxDynamicTableSize changes the dynamic header table size to v.
The actual size is bounded by the value passed to
SetMaxDynamicTableSizeLimit.
SetMaxDynamicTableSizeLimit changes the maximum value that can be
specified in SetMaxDynamicTableSize to v. By default, it is set to
4096, which is the same size of the default dynamic header table
size described in HPACK specification. If the current maximum
dynamic header table size is strictly greater than v, "Header Table
Size Update" will be done in the next WriteField call and the
maximum dynamic header table size is truncated to v.
WriteField encodes f into a single Write to e's underlying Writer.
This function may also produce bytes for "Header Table Size Update"
if necessary. If produced, it is done before encoding f.
func NewEncoder(w io.Writer) *Encoder
A HeaderField is a name-value pair. Both the name and value are
treated as opaque sequences of octets.
Name string
Sensitive means that this header field should never be
indexed.
Value string
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.
Size returns the size of an entry per RFC 7541 section 4.1.
( HeaderField) String() string
HeaderField : expvar.Var
HeaderField : fmt.Stringer
func (*Decoder).DecodeFull(p []byte) ([]HeaderField, error)
func (*Encoder).WriteField(f HeaderField) error
Package-Level Functions (total 6)
AppendHuffmanString appends s, as encoded in Huffman codes, to dst
and returns the extended buffer.
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.
HuffmanDecodeToString decodes the string in v.
HuffmanEncodeLength returns the number of bytes required to encode
s in Huffman codes. The result is round up to byte boundary.
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.
NewEncoder returns a new Encoder which performs HPACK encoding. An
encoded data is written to w.
Package-Level Variables (total 2)
ErrInvalidHuffman is returned for errors found decoding
Huffman-encoded strings.
ErrStringLength is returned by Decoder.Write when the max string length
(as configured by Decoder.SetMaxStringLength) would be violated.
The pages are generated with Golds v0.7.0-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |