http2: Index | Files

package hpack

import ""

Package hpack implements HPACK, a compression format for efficiently representing HTTP header fields in the context of HTTP/2.



Package Files

encode.go hpack.go huffman.go tables.go

func AppendHuffmanString Uses

func AppendHuffmanString(dst []byte, s string) []byte

AppendHuffmanString appends s, as encoded in Huffman codes, to dst and returns the extended buffer.

func HuffmanDecode Uses

func HuffmanDecode(w io.Writer, v []byte) (int, error)

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 HuffmanEncodeLength Uses

func HuffmanEncodeLength(s string) uint64

HuffmanEncodeLength returns the number of bytes required to encode s in Huffman codes. The result is round up to byte boundary.

type Decoder Uses

type Decoder struct {
    // contains filtered or unexported fields

A Decoder is the decoding context for incremental processing of header blocks.

func NewDecoder Uses

func NewDecoder(maxSize uint32, emitFunc func(f HeaderField)) *Decoder

func (*Decoder) Close Uses

func (d *Decoder) Close() error

func (*Decoder) DecodeFull Uses

func (d *Decoder) DecodeFull(p []byte) ([]HeaderField, error)

Decode decodes an entire block.

TODO: remove this method and make it incremental later? This is easier for debugging now.

func (*Decoder) SetAllowedMaxDynamicTableSize Uses

func (d *Decoder) SetAllowedMaxDynamicTableSize(v uint32)

SetAllowedMaxDynamicTableSize sets the upper bound that the encoded stream (via dynamic table size updates) may set the maximum size to.

func (*Decoder) SetMaxDynamicTableSize Uses

func (d *Decoder) SetMaxDynamicTableSize(v uint32)

func (*Decoder) Write Uses

func (d *Decoder) Write(p []byte) (n int, err error)

type DecodingError Uses

type DecodingError struct {
    Err error

A DecodingError is something the spec defines as a decoding error.

func (DecodingError) Error Uses

func (de DecodingError) Error() string

type Encoder Uses

type Encoder struct {
    // contains filtered or unexported fields

func NewEncoder Uses

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns a new Encoder which performs HPACK encoding. An encoded data is written to w.

func (*Encoder) SetMaxDynamicTableSize Uses

func (e *Encoder) SetMaxDynamicTableSize(v uint32)

SetMaxDynamicTableSize changes the dynamic header table size to v. The actual size is bounded by the value passed to SetMaxDynamicTableSizeLimit.

func (*Encoder) SetMaxDynamicTableSizeLimit Uses

func (e *Encoder) SetMaxDynamicTableSizeLimit(v uint32)

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.

func (*Encoder) WriteField Uses

func (e *Encoder) WriteField(f HeaderField) error

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.

type HeaderField Uses

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.

type InvalidIndexError Uses

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 Uses

func (e InvalidIndexError) Error() string

Package hpack imports 5 packages (graph) and is imported by 30 packages. Updated 2016-07-21. Refresh now. Tools for package owners.