codec/http3
lib/codec/http3.vklib/codec/http3.vk
Pure-Veko RFC 9000 QUIC variable-length integer codec, RFC 9114 HTTP/3 binary framing,
and RFC 9204 stateless QPACK header block encoder/decoder (sharing RFC 7541/9204 Huffman with codec/http2).
Zero capabilities required.
stream-control = fn [] i64
HTTP/3 unidirectional stream types (RFC 9114 Section 6.2).
stream-push = fn [] i64
stream-qpack-encoder = fn [] i64
stream-qpack-decoder = fn [] i64
frame-headers = fn [] i64
frame-cancel-push = fn [] i64
frame-settings = fn [] i64
frame-push-promise = fn [] i64
frame-goaway = fn [] i64
frame-max-push-id = fn [] i64
push-varint = fn [mut out bytes, v i64] any
Appends a 62-bit non-negative QUIC/HTTP/3 variable-length integer onto out.
encode-varint = fn [v i64] bytes
Encodes v into a standalone variable-length integer bytes slice.
use [h3 = codec/http3]
b1 = h3/encode-varint 37
b2 = h3/encode-varint 15293
b4 = h3/encode-varint 494878333
d1 = h3/decode-varint b1 0
d2 = h3/decode-varint b2 0
d4 = h3/decode-varint b4 0
if d1.val != 37 or d2.val != 15293 or d4.val != 494878333 [ err 'varint' ] else [ .ok ]
decode-varint = fn [b bytes, pos i64] any
Decodes one QUIC/HTTP/3 variable-length integer at pos, returning { val, next }.
encode-frame = fn [f H3Frame] bytes
Encodes an HTTP/3 H3Frame (varint(type) || varint(length) || payload).
decode-frame-at = fn [wire bytes, pos i64] any
Decodes a single HTTP/3 H3Frame at pos, returning { frame, next }.
encode-settings-frame = fn [settings map[i64]] bytes
Encodes HTTP/3 SETTINGS (map[i64] ID -> value) into a SETTINGS frame (0x04).
decode-settings-payload = fn [payload bytes] map[i64]
Decodes an HTTP/3 SETTINGS payload into map[i64].
qpack-encode = fn [headers block[h2/Header]] bytes
Encodes headers (block[h2/Header]) into a stateless RFC 9204 QPACK field section (RIC = 0, Delta Base = 0).
use [h2 = codec/http2, h3 = codec/http3]
hs = [
(h2/Header { name = ':method', value = 'GET' })
(h2/Header { name = ':path', value = '/stdlib' })
(h2/Header { name = 'x-veko-h3', value = 'quic-v1' })
]
blk = h3/qpack-encode hs
dec = h3/qpack-decode blk
if (len dec) != 3 or dec[0].value != 'GET' or dec[1].value != '/stdlib' or dec[2].value != 'quic-v1' [
err 'qpack roundtrip'
] else [ .ok ]
qpack-decode = fn [field_bytes bytes] block[h2/Header]
Decodes an RFC 9204 QPACK field section (Required Insert Count == 0 static + literal + Huffman) into block[h2/Header].