hpack: github.com/Jxck/hpack Index | Files | Directories

package hpack

import "github.com/Jxck/hpack"

Index

Package Files

context.go decoder.go dynamic_table.go encoder.go header_field.go header_list.go static_table.go type.go

Constants

const Version int = 9

Variables

var STATIC_HEADER_TABLE_SIZE = len(StaticTable)
var StaticTable = [...]HeaderField{
    {":authority", ""},
    {":method", "GET"},
    {":method", "POST"},
    {":path", "/"},
    {":path", "/index.html"},
    {":scheme", "http"},
    {":scheme", "https"},
    {":status", "200"},
    {":status", "204"},
    {":status", "206"},
    {":status", "304"},
    {":status", "400"},
    {":status", "404"},
    {":status", "500"},
    {"accept-charset", ""},
    {"accept-encoding", "gzip, deflate"},
    {"accept-language", ""},
    {"accept-ranges", ""},
    {"accept", ""},
    {"access-control-allow-origin", ""},
    {"age", ""},
    {"allow", ""},
    {"authorization", ""},
    {"cache-control", ""},
    {"content-disposition", ""},
    {"content-encoding", ""},
    {"content-language", ""},
    {"content-length", ""},
    {"content-location", ""},
    {"content-range", ""},
    {"content-type", ""},
    {"cookie", ""},
    {"date", ""},
    {"etag", ""},
    {"expect", ""},
    {"expires", ""},
    {"from", ""},
    {"host", ""},
    {"if-match", ""},
    {"if-modified-since", ""},
    {"if-none-match", ""},
    {"if-range", ""},
    {"if-unmodified-since", ""},
    {"last-modified", ""},
    {"link", ""},
    {"location", ""},
    {"max-forwards", ""},
    {"proxy-authenticate", ""},
    {"proxy-authorization", ""},
    {"range", ""},
    {"referer", ""},
    {"refresh", ""},
    {"retry-after", ""},
    {"server", ""},
    {"set-cookie", ""},
    {"strict-transport-security", ""},
    {"transfer-encoding", ""},
    {"user-agent", ""},
    {"vary", ""},
    {"via", ""},
    {"www-authenticate", ""},
}

func Decode Uses

func Decode(wire []byte) (frames []Frame)

Decode Wire byte seq to Slice of Frames

func DecodeLiteral Uses

func DecodeLiteral(buf *swrap.SWrap) (value string)

func DecodePrefixedInteger Uses

func DecodePrefixedInteger(buf *swrap.SWrap, N uint8) uint32

read N prefixed Integer from buffer as uint32

func DecodeString Uses

func DecodeString(buf *swrap.SWrap, n uint32) string

read n byte from buffer as string

type Context Uses

type Context struct {
    HT  *DynamicTable
    ES  *HeaderList
}

func NewContext Uses

func NewContext(SETTINGS_HEADER_TABLE_SIZE uint32) *Context

func (*Context) ChangeSize Uses

func (c *Context) ChangeSize(size uint32)

func (*Context) Decode Uses

func (c *Context) Decode(wire []byte)

func (*Context) Encode Uses

func (c *Context) Encode(headerList HeaderList) []byte

func (*Context) Eviction Uses

func (c *Context) Eviction()

removing entry from top until make space of size in Header Table

func (*Context) Push Uses

func (c *Context) Push(hf *HeaderField)

Push new enctory to Header Table and Eviction

func (*Context) String Uses

func (c *Context) String() string

String for Debug

type DynamicTable Uses

type DynamicTable struct {
    DYNAMIC_TABLE_SIZE uint32
    HeaderFields       []*HeaderField
}

The dynamic table is a table that associates stored header fields with index values. This table is dynamic and specific to an encoding or decoding context.

func NewDynamicTable Uses

func NewDynamicTable(SETTINGS_HEADER_TABLE_SIZE uint32) *DynamicTable

func (*DynamicTable) Len Uses

func (ht *DynamicTable) Len() int

get length of Dynamic Table

func (*DynamicTable) Push Uses

func (ht *DynamicTable) Push(hf *HeaderField)

push new Header Field to top of DynamicTable with eviction

func (*DynamicTable) Remove Uses

func (ht *DynamicTable) Remove(index int) *HeaderField

remove Header at index i

func (*DynamicTable) Size Uses

func (ht *DynamicTable) Size() uint32

get total size of Dynamic Table

func (*DynamicTable) String Uses

func (ht *DynamicTable) String() (str string)

String for Debug

type DynamicTableSizeUpdate Uses

type DynamicTableSizeUpdate struct {
    MaxSize uint32
}

0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ | 0 | 0 | 1 | Max size (5+) | +---+---------------------------+ Maximum Dynamic Table Size Update

func NewDynamicTableSizeUpdate Uses

func NewDynamicTableSizeUpdate(maxSize uint32) (frame *DynamicTableSizeUpdate)

func (*DynamicTableSizeUpdate) Encode Uses

func (frame *DynamicTableSizeUpdate) Encode() (buf *swrap.SWrap)

func (DynamicTableSizeUpdate) String Uses

func (f DynamicTableSizeUpdate) String() string

type Frame Uses

type Frame interface {
    Encode() *swrap.SWrap
}

func DecodeHeader Uses

func DecodeHeader(buf *swrap.SWrap) Frame

Decode single Frame from buffer and return it

type HeaderField Uses

type HeaderField struct {
    Name  string
    Value string
}

A name-value pair. Both the name and value are treated as opaque sequences of octets.

func NewHeaderField Uses

func NewHeaderField(name, value string) *HeaderField

func (*HeaderField) Size Uses

func (h *HeaderField) Size() uint32

The size of an entry is the sum of its name's length in octets of its value's length in octets and of 32 octets.

type HeaderList Uses

type HeaderList []*HeaderField

A header list is an ordered collection of header fields that are encoded jointly and can contain duplicate header fields. A complete list of header fields contained in an HTTP/2 header block is a header list.

func NewHeaderList Uses

func NewHeaderList() *HeaderList

func ToHeaderList Uses

func ToHeaderList(header http.Header) *HeaderList

func (*HeaderList) Emit Uses

func (hl *HeaderList) Emit(hf *HeaderField)

func (*HeaderList) Len Uses

func (hl *HeaderList) Len() int

func (*HeaderList) Less Uses

func (hl *HeaderList) Less(i, j int) bool

func (HeaderList) String Uses

func (hl HeaderList) String() (str string)

func (*HeaderList) Swap Uses

func (hl *HeaderList) Swap(i, j int)

Sort Interface

func (HeaderList) ToHeader Uses

func (hl HeaderList) ToHeader() http.Header

convert to http.Header

type IndexedHeader Uses

type IndexedHeader struct {
    Index uint32
}

Indexed Header Field

0   1   2   3   4   5   6   7

+---+---+---+---+---+---+---+---+ | 1 | Index (7+) | +---+---------------------------+

func NewIndexedHeader Uses

func NewIndexedHeader(index uint32) (frame *IndexedHeader)

func (*IndexedHeader) Encode Uses

func (frame *IndexedHeader) Encode() (buf *swrap.SWrap)

type IndexedLiteral Uses

type IndexedLiteral struct {
    Indexing    Indexing
    Index       uint32
    ValueLength uint32
    ValueString string
}

Literal Header Field with Incremental Indexing - Indexed Name | 0 | 1 | Index (6+) |

Literal Header Field without Indexing - Indexed Name | 0 | 0 | 0 | 0 | Index (4+) |

Literal Header Field never Indexed - Indexed Nmae | 0 | 0 | 0 | 1 | Index (4+) |

0   1   2   3   4   5   6   7

+---+---+---+---+---+---+---+---+ | 0 | Flag + Index | +---+---+---+-------------------+ | H | Value Length (7+) | +-------------------------------+ | Value String (Length octets) | +-------------------------------+

func NewIndexedLiteral Uses

func NewIndexedLiteral(indexing Indexing, index uint32, value string) (frame *IndexedLiteral)

func (*IndexedLiteral) Encode Uses

func (frame *IndexedLiteral) Encode() (buf *swrap.SWrap)

func (*IndexedLiteral) EncodeHuffman Uses

func (frame *IndexedLiteral) EncodeHuffman() (buf *swrap.SWrap)

func (IndexedLiteral) String Uses

func (f IndexedLiteral) String() string

type Indexing Uses

type Indexing int
const (
    WITH Indexing = iota
    WITHOUT
    NEVER
)

func (Indexing) String Uses

func (i Indexing) String() string

type StringLiteral Uses

type StringLiteral struct {
    Indexing    Indexing
    Index       uint32
    NameLength  uint32
    NameString  string
    ValueLength uint32
    ValueString string
}

Literal Header Field with Incremental Indexing - New Name | 0 | 1 | 0 | = 64

Literal Header Field without Indexing - New Name | 0 | = 0

Literal Header Field never Indexed - New Name | 0 | 1 | 0 | = 16

0   1   2   3   4   5   6   7

+---+---+---+---+---+---+---+---+ | Flag=( 0 | 16 | 64 ) | +---+---+---+-------------------+ | H | Name Length (7+) | +-------------------------------+ | Name String (Length octets) | +-------------------------------+ | H | Value Length (7+) | +-------------------------------+ | Value String (Length octets) | +-------------------------------+

func NewStringLiteral Uses

func NewStringLiteral(indexing Indexing, name, value string) (frame *StringLiteral)

func (*StringLiteral) Encode Uses

func (frame *StringLiteral) Encode() (buf *swrap.SWrap)

func (*StringLiteral) EncodeHuffman Uses

func (frame *StringLiteral) EncodeHuffman() (buf *swrap.SWrap)

func (StringLiteral) String Uses

func (f StringLiteral) String() string

Directories

PathSynopsis
huffman
integer_representation

Package hpack imports 10 packages (graph) and is imported by 1 packages. Updated 2016-08-01. Refresh now. Tools for package owners.