HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

  • Packagehttp2-5.4.8
  • Exports32
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceHPACK.hs

Encoding and decoding

A full HTTP header field with the name and value separated.

E.g. "Content-Length: 28" parsed into a Header would turn into ("Content-Length", "28")

valuemk :: FoldCase s => s -> CI s

Make the given string-like value case insensitive.

Encoding and decoding with token

valueencodeTokenHeader
  1. :: Buffer
  2. -> BufferSize
  3. -> EncodeStrategy
  4. -> Bool

    True at the first time, False when continued.

  5. -> DynamicTable
  6. -> TokenHeaderList
  7. -> 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.

Converting the HPACK format 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.

  • IllegalHeaderName and TooLargeHeader are 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.

  • DecodeError would be thrown if the HPACK format is broken.

DynamicTable

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

Example1 expression
defaultDynamicTableSize4096

Strategy for encoding

Errors

datadata DecodeError

Errors for decoder.

Constructors

Instances3Eq, Show, Exception

Token header

Value table

Basic types