Safe Haskell | None |
---|---|
Language | Haskell2010 |
HPACK(https://tools.ietf.org/html/rfc7541) encoding and decoding a header list.
- encodeHeader :: EncodeStrategy -> Size -> DynamicTable -> HeaderList -> IO ByteString
- decodeHeader :: DynamicTable -> ByteString -> IO HeaderList
- encodeHeaderBuffer :: Buffer -> BufferSize -> EncodeStrategy -> Bool -> DynamicTable -> HeaderList -> IO (HeaderList, Int)
- data DynamicTable
- defaultDynamicTableSize :: Int
- newDynamicTableForEncoding :: Size -> IO DynamicTable
- newDynamicTableForDecoding :: Size -> Size -> IO DynamicTable
- clearDynamicTable :: DynamicTable -> IO ()
- withDynamicTableForEncoding :: Size -> (DynamicTable -> IO a) -> IO a
- withDynamicTableForDecoding :: Size -> Size -> (DynamicTable -> IO a) -> IO a
- setLimitForEncoding :: Size -> DynamicTable -> IO ()
- data CompressionAlgo
- data EncodeStrategy = EncodeStrategy {}
- defaultEncodeStrategy :: EncodeStrategy
- data DecodeError
- data BufferOverrun = BufferOverrun
- type HeaderList = [Header]
- type Header = (HeaderName, HeaderValue)
- type HeaderName = ByteString
- type HeaderValue = ByteString
- type Size = Int
- type Index = Int
- type Buffer = Ptr Word8
- type BufferSize = Int
Encoding and decoding
:: EncodeStrategy | |
-> Size | The size of a temporary buffer. |
-> DynamicTable | |
-> HeaderList | |
-> IO ByteString | An HPACK format |
Converting HeaderList
to the HPACK format.
BufferOverrun
will be thrown if the temporary buffer is too small.
:: DynamicTable | |
-> ByteString | An HPACK format |
-> IO HeaderList |
Converting the HPACK format to HeaderList
.
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 in a buffer
:: Buffer | |
-> BufferSize | |
-> EncodeStrategy | |
-> Bool | |
-> DynamicTable | |
-> HeaderList | |
-> IO (HeaderList, Int) | Leftover |
Converting HeaderList
to the HPACK format directly in the buffer.
4th argument is relating to dynamic table size update.
When calling this function for a new HeaderList
,
it must be True
.
If True
and set by setLimitForEncoding
,
dynamic table size update is generated at the beginning of
the HPACK format.
If the buffer for encoding is small, leftover HeaderList
will
be returned. In this case, this function should be called with it
again. 4th argument must be False
.
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 #
:: Size | The dynamic table size |
-> IO DynamicTable |
Creating DynamicTable
for encoding.
newDynamicTableForDecoding Source #
:: Size | The dynamic table size |
-> Size | The size of temporary buffer for Huffman decoding |
-> IO DynamicTable |
Creating DynamicTable
for decoding.
clearDynamicTable :: DynamicTable -> IO () Source #
Clearing DynamicTable
.
Currently, this frees the temporary buffer for Huffman decoding.
withDynamicTableForEncoding Source #
:: Size | The dynamic table size |
-> (DynamicTable -> IO a) | |
-> IO a |
Creating DynamicTable
for encoding,
performing the action and
clearing the DynamicTable
.
withDynamicTableForDecoding Source #
:: 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
data CompressionAlgo Source #
Compression algorithms for HPACK encoding.
data EncodeStrategy Source #
Strategy for HPACK encoding.
EncodeStrategy | |
|
defaultEncodeStrategy :: EncodeStrategy Source #
Default EncodeStrategy
.
>>>
defaultEncodeStrategy
EncodeStrategy {compressionAlgo = Linear, useHuffman = False}
Errors
data DecodeError Source #
Errors for decoder.
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 |
TooSmallTableSize | A peer set the dynamic table size less than 32 |
TooLargeTableSize | A peer tried to change the dynamic table size over the limit |
IllegalTableSizeUpdate | Table size update at the non-beginning |
HeaderBlockTruncated |
data BufferOverrun Source #
BufferOverrun | The buffer size is not enough |
Headers
type HeaderList = [Header] Source #
Header list.
type Header = (HeaderName, HeaderValue) Source #
Header.
type HeaderName = ByteString Source #
Header name.
type HeaderValue = ByteString Source #
Header value.
Basic types
type BufferSize = Int Source #
The size of buffer.