nhttp_qpack_interop (nhttp_lib v1.0.0)
View SourceQPACK Interop Format (QIF) parser and encoded file handler.
Implements the offline interop testing format described at: https://github.com/quicwg/base-drafts/wiki/QPACK-Offline-Interop
QIF is a plain-text format where each field line is on a separate line with name and value separated by a TAB character. Empty lines delimit field sections. Lines starting with '#' are comments.
The binary encoded output format is:
File = Block*
Block = StreamId(64bit) | Length(32bit) | QPACKDataStreamId 0 carries encoder stream data. StreamId 1+ carry request stream field section data.
Summary
Functions
Decode the binary interop file format using the QPACK decoder. Reads blocks sequentially: StreamId=0 blocks are fed as encoder stream data, other blocks are decoded as field sections. Returns the decoded field sections in order.
Encode QIF field sections to the binary interop file format. For each field section, emits encoder stream blocks (StreamId=0) and a request stream block (StreamId=N). The decoder can replay these blocks in order.
Parse a QIF text file into a list of field sections.
Write field sections back to QIF text format.
Types
-type block() :: #{stream_id := nhttp_lib:stream_id(), data := binary()}.
-type interop_config() :: #{max_table_capacity => non_neg_integer(), max_blocked_streams => non_neg_integer(), huffman => boolean()}.
-type qif() :: [[nhttp_qpack:field_line()]].
Functions
-spec decode_from_file(binary(), interop_config()) -> {ok, qif()} | {error, term()}.
Decode the binary interop file format using the QPACK decoder. Reads blocks sequentially: StreamId=0 blocks are fed as encoder stream data, other blocks are decoded as field sections. Returns the decoded field sections in order.
-spec encode_to_file(qif(), interop_config()) -> {ok, iodata()} | {error, term()}.
Encode QIF field sections to the binary interop file format. For each field section, emits encoder stream blocks (StreamId=0) and a request stream block (StreamId=N). The decoder can replay these blocks in order.
Parse a QIF text file into a list of field sections.
Each field section is a list of {Name, Value} tuples. Sections are
separated by empty lines. Lines starting with '#' are comments.
Write field sections back to QIF text format.