http2-1.4.3: HTTP/2.0 library including frames and HPACK

Safe HaskellNone
LanguageHaskell2010

Network.HPACK

Contents

Description

HPACK(https://tools.ietf.org/html/rfc7541) encoding and decoding a header list.

Synopsis

Encoding and decoding

encodeHeader :: EncodeStrategy -> HPACKEncoding Source

Converting HeaderList for HTTP header to the low level format.

decodeHeader :: HPACKDecoding Source

Converting the low level format for HTTP header to HeaderList. DecodeError would be thrown.

Encoding with builders

encodeHeaderBuilder :: EncodeStrategy -> HPACKEncodingBuilder Source

Converting HeaderList for HTTP header to bytestring builder.

DynamicTable

data DynamicTable Source

Type for dynamic table.

defaultDynamicTableSize :: Int Source

Default dynamic table size. The value is 4,096 bytes: an array has 128 entries.

>>> defaultDynamicTableSize
4096

setLimitForEncoding :: Size -> DynamicTable -> IO () Source

When SETTINGS_HEADER_TABLE_SIZE is received from a peer, its value should be set by this function.

Strategy for encoding

data CompressionAlgo Source

Compression algorithms for HPACK encoding.

Constructors

Naive

No compression

Static

Using the static table only

Linear

Using indices only

data EncodeStrategy Source

Strategy for HPACK encoding.

Constructors

EncodeStrategy 

Fields

compressionAlgo :: !CompressionAlgo

Which compression algorithm is used.

useHuffman :: !Bool

Whether or not to use Huffman encoding for strings.

defaultEncodeStrategy :: EncodeStrategy Source

Default EncodeStrategy.

>>> defaultEncodeStrategy
EncodeStrategy {compressionAlgo = Linear, useHuffman = True}

Errors for decoding

data DecodeError Source

Errors for decoder.

Constructors

IndexOverrun Index

Index is out of range

EosInTheMiddle

Eos appears in the middle of huffman string

IllegalEos

Non-eos appears in the end of huffman string

TooLongEos

Eos of huffman string is more than 7 bits

EmptyEncodedString

Encoded string has no length

EmptyBlock

Header block is empty

TooLargeTableSize

A peer tried to change the dynamic table size over the limit

IllegalTableSizeUpdate

Table size update at the non-beginning

Headers

type HeaderList = [Header] Source

Header list.

type HeaderName = ByteString Source

Header name.

type HeaderValue = ByteString Source

Header value.

Basic types

type Size = Int Source

Size in bytes.

type Index = Int Source

Index for table.