| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.HPACK.Internal
Synopsis
- encodeI :: WriteBuffer -> (Word8 -> Word8) -> Int -> Int -> IO ()
- encodeInteger :: Int -> Int -> IO ByteString
- decodeI :: Int -> Word8 -> ReadBuffer -> IO Int
- decodeInteger :: Int -> Word8 -> ByteString -> IO Int
- integerLimit :: Int
- encodeString :: Bool -> ByteString -> IO ByteString
- encodeS :: WriteBuffer -> Bool -> (Word8 -> Word8) -> (Word8 -> Word8) -> Int -> ByteString -> IO ()
- decodeString :: ReadBuffer -> IO ByteString
- toTokenHeaderTable :: [Header] -> IO TokenHeaderTable
- decodeS :: (Word8 -> Word8) -> (Word8 -> Bool) -> Int -> HuffmanDecoder -> ReadBuffer -> IO ByteString
- decodeSimple :: (Word8 -> ReadBuffer -> IO TokenHeader) -> ReadBuffer -> IO [Header]
- decodeSophisticated :: (Word8 -> ReadBuffer -> IO TokenHeader) -> ReadBuffer -> IO TokenHeaderTable
- type GCBuffer = ForeignPtr Word8
- encodeH :: WriteBuffer -> ByteString -> IO Int
- encodeHuffman :: ByteString -> IO ByteString
- decodeH :: GCBuffer -> BufferSize -> ReadBuffer -> Int -> IO ByteString
- decodeHuffman :: ByteString -> IO ByteString
- type HuffmanDecoder = ReadBuffer -> Int -> IO ByteString
- decH :: WriteBuffer -> ReadBuffer -> Int -> IO ()
- type Size = Int
- type FieldValue = ByteString
- type Index = Int
- data Entry = Entry Size Token FieldValue
- toEntry :: Header -> Entry
- toEntryToken :: Token -> FieldValue -> Entry
- entrySize :: Entry -> Size
- entryTokenHeader :: Entry -> TokenHeader
- entryToken :: Entry -> Token
- entryHeaderName :: Entry -> HeaderName
- entryFieldValue :: Entry -> FieldValue
- dummyEntry :: Entry
- maxNumbers :: Size -> Int
- data CompressionAlgo
- data EncodeStrategy = EncodeStrategy {}
Integer encoding/decoding
Integer encoding with a write buffer.
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]
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.
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.empty10>>>decodeInteger 5 31 $ BS.pack [154,10]1337>>>decodeInteger 8 42 $ BS.empty42
integerLimit :: Int Source #
The largest integer decodeI will return.
HPACK's integer encoding carries no bound of its own, so a decoder has to impose one. RFC 7541, section 5.1: "Integer encodings that exceed implementation limits -- in value or octet length -- MUST be treated as decoding errors."
2^30 - 1 is far above anything HTTP/2 can ask for -- a frame payload is at
most 2^24 - 1 octets, so no length or index comes near it -- and it still
fits in an Int on a platform where that is 32 bits wide.
>>>integerLimit1073741823
String encoding/decoding
Arguments
| :: Bool | Use Huffman if efficient |
| -> ByteString | Target |
| -> IO ByteString |
String encoding (7+) with a temporary buffer whose size is 4096.
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 Source #
String decoding (7+) with a temporal Huffman decoder whose buffer is 4096.
toTokenHeaderTable :: [Header] -> IO TokenHeaderTable Source #
Converting a header list of the http-types style to
TokenHeaderList and ValueTable.
Arguments
| :: (Word8 -> Word8) | Dropping prefix and Huffman |
| -> (Word8 -> Bool) | Checking Huffman flag |
| -> Int | N+ |
| -> HuffmanDecoder | |
| -> ReadBuffer | |
| -> IO ByteString |
String decoding with Huffman decoder.
decodeSimple :: (Word8 -> ReadBuffer -> IO TokenHeader) -> ReadBuffer -> IO [Header] Source #
Converting to '[Header]'.
- Headers are decoded as is.
DecodeErrorwould be thrown if the HPACK format is broken.
decodeSophisticated :: (Word8 -> ReadBuffer -> IO TokenHeader) -> ReadBuffer -> IO TokenHeaderTable Source #
Converting to TokenHeaderList and ValueTable.
- Multiple values of Cookie: are concatenated.
- If a pseudo header appears multiple times,
IllegalHeaderNameis thrown. - If unknown pseudo headers appear,
IllegalHeaderNameis thrown. - If pseudo headers are found after normal headers,
IllegalHeaderNameis thrown. - If a header key contains capital letters,
IllegalHeaderNameis thrown. - If the number of header fields is too large,
TooLargeHeaderis thrown IllegalHeaderNameandTooLargeHeaderare thrown only once the whole block has been decoded, so that the dynamic table is up to date: the message is malformed, not the block.DecodeErrorwould be thrown if the HPACK format is broken.
The decoded size of the block is not limited: see decodeTokenHeader
and setHeaderListSizeLimit for that.
type GCBuffer = ForeignPtr Word8 Source #
Arguments
| :: WriteBuffer | |
| -> ByteString | Target |
| -> IO Int | The length of the encoded string. |
Huffman encoding.
encodeHuffman :: ByteString -> IO ByteString Source #
Huffman encoding with a temporary buffer whose size is 4096.
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 Source #
Huffman decoding.
type HuffmanDecoder = ReadBuffer -> Int -> IO ByteString Source #
Huffman decoding.
decH :: WriteBuffer -> ReadBuffer -> Int -> IO () Source #
Low devel Huffman decoding in a write buffer.
type FieldValue = ByteString #
Field value.
Type for table entry. Size includes the 32 bytes magic number.
Constructors
| Entry Size Token FieldValue |
toEntryToken :: Token -> FieldValue -> Entry Source #
entryTokenHeader :: Entry -> TokenHeader Source #
Getting TokenHeader.
entryHeaderName :: Entry -> HeaderName Source #
Getting HeaderName.
entryFieldValue :: Entry -> FieldValue Source #
Getting FieldValue.
dummyEntry :: Entry Source #
Dummy Entry to initialize a dynamic table.
maxNumbers :: Size -> Int Source #
How many entries can be stored in a dynamic table?
Types
data CompressionAlgo Source #
Compression algorithms for HPACK encoding.
Instances
| Show CompressionAlgo Source # | |
Defined in Network.HPACK.Types Methods showsPrec :: Int -> CompressionAlgo -> ShowS # show :: CompressionAlgo -> String # showList :: [CompressionAlgo] -> ShowS # | |
| Eq CompressionAlgo Source # | |
Defined in Network.HPACK.Types Methods (==) :: CompressionAlgo -> CompressionAlgo -> Bool # (/=) :: CompressionAlgo -> CompressionAlgo -> Bool # | |
data EncodeStrategy Source #
Strategy for HPACK encoding.
Constructors
| EncodeStrategy | |
Fields
| |
Instances
| Show EncodeStrategy Source # | |
Defined in Network.HPACK.Types Methods showsPrec :: Int -> EncodeStrategy -> ShowS # show :: EncodeStrategy -> String # showList :: [EncodeStrategy] -> ShowS # | |
| Eq EncodeStrategy Source # | |
Defined in Network.HPACK.Types Methods (==) :: EncodeStrategy -> EncodeStrategy -> Bool # (/=) :: EncodeStrategy -> EncodeStrategy -> Bool # | |