http2-4.2.2: HTTP/2 library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.HPACK.Internal

Synopsis

Integer encoding/decoding

encodeI #

Arguments

:: WriteBuffer 
-> (Word8 -> Word8)

Setting prefix

-> Int

N+

-> Int

Target

-> IO () 

Integer encoding with a write buffer.

encodeInteger #

Arguments

:: Int

N+

-> Int

Target

-> IO ByteString 

Encoding integer with a temporary buffer whose size is 4096. No prefix is set.

>>> BS.unpack <$> encodeInteger 5 10
[10]
>>> BS.unpack <$> encodeInteger 5 1337
[31,154,10]
>>> BS.unpack <$> encodeInteger 8 42
[42]

decodeI #

Arguments

:: Int

N+

-> Word8

The head of encoded integer whose prefix is already dropped

-> ReadBuffer 
-> IO Int 

Integer decoding with a read buffer. The first argument is N of prefix.

decodeInteger #

Arguments

:: Int

N+

-> Word8

The head of encoded integer whose prefix is already dropped

-> ByteString

The tail of encoded integer

-> IO Int 

Integer decoding. The first argument is N of prefix.

>>> decodeInteger 5 10 $ BS.empty
10
>>> decodeInteger 5 31 $ BS.pack [154,10]
1337
>>> decodeInteger 8 42 $ BS.empty
42

String encoding/decoding

encodeString #

Arguments

:: Bool

Use Huffman if efficient

-> ByteString

Target

-> IO ByteString 

String encoding (7+) with a temporary buffer whose size is 4096.

encodeS #

Arguments

:: WriteBuffer 
-> Bool

Use Huffman if efficient

-> (Word8 -> Word8)

Setting prefix

-> (Word8 -> Word8)

Setting huffman flag

-> Int

N+

-> ByteString

Target

-> IO () 

String encoding. The algorithm based on copy avoidance and selection of better result of huffman or raw.

decodeString :: ReadBuffer -> IO ByteString #

String decoding (7+) with a temporal Huffman decoder whose buffer is 4096.

decodeS #

Arguments

:: (Word8 -> Word8)

Dropping prefix and Huffman

-> (Word8 -> Bool)

Checking Huffman flag

-> Int

N+

-> HuffmanDecoder 
-> ReadBuffer 
-> IO ByteString 

String decoding with Huffman decoder.

decodeSophisticated :: (Word8 -> ReadBuffer -> IO TokenHeader) -> ReadBuffer -> IO HeaderTable #

Converting to TokenHeaderList and ValueTable.

  • Multiple values of Cookie: are concatenated.
  • If a pseudo header appears multiple times, IllegalHeaderName is thrown.
  • If unknown pseudo headers appear, IllegalHeaderName is thrown.
  • If pseudo headers are found after normal headers, IllegalHeaderName is thrown.
  • If a header key contains capital letters, IllegalHeaderName is thrown.
  • If the number of header fields is too large, TooLargeHeader is thrown
  • DecodeError would be thrown if the HPACK format is broken.
  • BufferOverrun will be thrown if the temporary buffer for Huffman decoding is too small.

decodeSimple :: (Word8 -> ReadBuffer -> IO TokenHeader) -> ReadBuffer -> IO HeaderList #

Converting 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.

Huffman encoding/decoding

encodeH #

Arguments

:: WriteBuffer 
-> ByteString

Target

-> IO Int

The length of the encoded string.

Huffman encoding.

encodeHuffman :: ByteString -> IO ByteString #

Huffman encoding with a temporary buffer whose size is 4096.

decodeH #

Arguments

:: GCBuffer

A working space

-> BufferSize 
-> ReadBuffer

A read buffer which contains the target

-> Int

The target length

-> IO ByteString 

Huffman decoding.

decodeHuffman :: ByteString -> IO ByteString #

Huffman decoding with a temporary buffer whose size is 4096.

type HuffmanDecoder = ReadBuffer -> Int -> IO ByteString #

Huffman decoding.

decH :: WriteBuffer -> ReadBuffer -> Int -> IO () #

Low devel Huffman decoding in a write buffer.

Type

type Size = Int #

Size in bytes.

data Entry #

Type for table entry. Size includes the 32 bytes magic number.

Constructors

Entry Size Token HeaderValue 

Instances

Instances details
Show Entry # 
Instance details

Defined in Network.HPACK.Table.Entry

Methods

showsPrec :: Int -> Entry -> ShowS

show :: Entry -> String

showList :: [Entry] -> ShowS

type Header = (HeaderName, HeaderValue) #

Header.

type HeaderName = ByteString #

Header name.

type HeaderValue = ByteString #

Header value.

type Index = Int #

Index for table.

Header and Entry

Getters

entrySize :: Entry -> Size #

Getting the size of Entry.

entryToken :: Entry -> Token #

Getting Token.

For initialization

dummyEntry :: Entry #

Dummy Entry to initialize a dynamic table.

maxNumbers :: Size -> Int #

How many entries can be stored in a dynamic table?