http2-3.0.3: HTTP/2 library
Safe Haskell None
Language Haskell2010

Network.HPACK

Description

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

Synopsis

Encoding and decoding

encodeHeader Source #

Arguments

:: EncodeStrategy
-> Size

The size of a temporary buffer.

-> DynamicTable
-> HeaderList
-> IO ByteString

An HPACK format

Converting HeaderList to the HPACK format. This function has overhead of allocating/freeing a temporary buffer. BufferOverrun will be thrown if the temporary buffer is too small.

decodeHeader Source #

Arguments

:: DynamicTable
-> ByteString

An HPACK format

-> IO HeaderList

Converting the HPACK format to HeaderList .

  • Headers are decoded as is.
  • DecodeError would be thrown if the HPACK format is broken.
  • BufferOverrun will be thrown if the temporary buffer for Huffman decoding is too small.

Encoding and decoding with token

encodeTokenHeader Source #

Arguments

:: Buffer
-> BufferSize
-> EncodeStrategy
-> Bool

True at the first time, False when continued.

-> DynamicTable
-> TokenHeaderList
-> IO ( TokenHeaderList , Int )

Leftover, filled length

Converting TokenHeaderList to the HPACK format directly in the buffer.

When calling this function for a new TokenHeaderList , 4th argument must be True .

The return value is a pair of leftover TokenHeaderList and how many bytes are filled in the buffer. If the leftover is empty, the encoding is finished. Otherwise, this function should be called with it again. 4th argument must be False .

4th argument is relating to dynamic table size update. If True and the limit is set by setLimitForEncoding , dynamic table size update is generated at the beginning of the HPACK format.

decodeTokenHeader Source #

Arguments

:: DynamicTable
-> ByteString

An HPACK format

-> IO HeaderTable

Converting the HPACK format to TokenHeaderList and ValueTable .

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

newDynamicTableForEncoding Source #

Arguments

:: Size

The dynamic table size

-> IO DynamicTable

Creating DynamicTable for encoding.

newDynamicTableForDecoding Source #

Arguments

:: Size

The dynamic table size

-> Size

The size of temporary buffer for Huffman decoding

-> IO DynamicTable

Creating DynamicTable for decoding.

withDynamicTableForEncoding Source #

Arguments

:: Size

The dynamic table size

-> ( DynamicTable -> IO a)
-> IO a

Creating DynamicTable for encoding, performing the action and clearing the DynamicTable .

withDynamicTableForDecoding Source #

Arguments

:: Size

The dynamic table size

-> Size

The size of temporary buffer for Huffman

-> ( DynamicTable -> IO a)
-> IO a

Creating DynamicTable for decoding, performing the action and clearing the DynamicTable .

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

defaultEncodeStrategy :: EncodeStrategy Source #

Default EncodeStrategy .

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

Errors

Headers

type HeaderList = [ Header ] Source #

Header list.

type TokenHeaderList = [ TokenHeader ] Source #

TokenBased header list.

Value table

type ValueTable = Array Int ( Maybe HeaderValue ) Source #

An array to get HeaderValue quickly. getHeaderValue should be used. Internally, the key is Token ix .

type HeaderTable = ( TokenHeaderList , ValueTable ) Source #

A pair of token list and value table.

Basic types

type Size = Int Source #

Size in bytes.

type Index = Int Source #

Index for table.

type BufferSize = Int Source #

Size of a buffer.

Re-exports

original :: CI s -> s Source #

Retrieve the original string-like value.

foldedCase :: CI s -> s Source #

Retrieve the case folded string-like value. (Also see foldCase ).

mk :: FoldCase s => s -> CI s Source #

Make the given string-like value case insensitive.