veko doc
Self-Contained API Reference • Gradual Types • Capabilities • Wasm Sandbox

codec/http3

lib/codec/http3.vk

lib/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.

signature
stream-control = fn [] i64

HTTP/3 unidirectional stream types (RFC 9114 Section 6.2).

signature
stream-push = fn [] i64
signature
stream-qpack-encoder = fn [] i64
signature
stream-qpack-decoder = fn [] i64
signature
frame-data = fn [] i64

HTTP/3 frame types (RFC 9114 Section 7.2).

signature
frame-headers = fn [] i64
signature
frame-cancel-push = fn [] i64
signature
frame-settings = fn [] i64
signature
frame-push-promise = fn [] i64
signature
frame-goaway = fn [] i64
signature
frame-max-push-id = fn [] i64
H3Frame struct
signature
H3Frame = struct { ftype i64, payload bytes }

Decoded HTTP/3 frame (ftype + payload).

signature
push-varint = fn [mut out bytes, v i64] any

Appends a 62-bit non-negative QUIC/HTTP/3 variable-length integer onto out.

signature
encode-varint = fn [v i64] bytes

Encodes v into a standalone variable-length integer bytes slice.

Executable Example
veko
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 ]
signature
decode-varint = fn [b bytes, pos i64] any

Decodes one QUIC/HTTP/3 variable-length integer at pos, returning { val, next }.

signature
encode-frame = fn [f H3Frame] bytes

Encodes an HTTP/3 H3Frame (varint(type) || varint(length) || payload).

signature
decode-frame-at = fn [wire bytes, pos i64] any

Decodes a single HTTP/3 H3Frame at pos, returning { frame, next }.

signature
encode-settings-frame = fn [settings map[i64]] bytes

Encodes HTTP/3 SETTINGS (map[i64] ID -> value) into a SETTINGS frame (0x04).

signature
decode-settings-payload = fn [payload bytes] map[i64]

Decodes an HTTP/3 SETTINGS payload into map[i64].

signature
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).

Executable Example
veko
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 ]
signature
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].