net/http3
lib/net/http3.vklib/net/http3.vk
Pure-Veko RFC 9000 QUIC v1 transport, RFC 9001 QUIC-TLS packet/header protection,
and RFC 9114 HTTP/3 multiplexed UDP client & server over net/udp-* and codec/http3.
Message = struct { stream_id i64, status i64 = ..., method str = ..., path str = ..., headers map[str] = ..., body bytes }
HTTP/3 request/response message exchanged over a QUIC stream.
derive-quic-keys = fn [secret bytes, cs i64] map
derive-initial-keys = fn [client_dcid bytes] map
Derives Initial client & server QUIC v1 keysets from the client's Initial Destination Connection ID (dcid).
use [h3 = net/http3, hex = codec/hex]
dcid = hex/decode '8394c8f03e515708'
init = h3/derive-initial-keys dcid
if (hex/encode init.client.key) != '1f369613dd76d5467730efcbe3b1a22d' or (len init.client.key) != 16 [
err 'quic initial key len'
] else [ .ok ]
seal-long-packet = fn [ptype i64, dcid bytes, scid bytes, pn i64, ks map, raw_frames bytes, pad_to i64] bytes
Seals a Long Header QUIC v1 packet (ptype: 0 = Initial, 2 = Handshake) with 2-byte packet number.
seal-short-packet = fn [dcid bytes, pn i64, ks map, raw_frames bytes] bytes
Seals a Short Header (1-RTT) QUIC v1 packet with 2-byte packet number.
reconstruct-pn = fn [largest_pn i64, truncated_pn i64, pn_nbits i64] i64
RFC 9000 Appendix A.3 packet number reconstruction from wire-truncated truncated_pn (pn_nbits in 8, 16, 24, 32).
open-long-packet-pn = fn [dgram bytes, off i64, ks map, largest_pn i64] any
Parses & unprotects one Long Header packet at off inside UDP dgram, reconstructing full 62-bit PN from largest_pn.
open-long-packet = fn [dgram bytes, off i64, ks map] any
Parses & unprotects one Long Header packet at off inside UDP dgram.
open-short-packet-pn = fn [dgram bytes, off i64, local_cid_len i64, ks map, largest_pn i64] any
Parses & unprotects a Short Header (1-RTT) packet from off to the end of dgram, reconstructing PN from largest_pn.
open-short-packet = fn [dgram bytes, off i64, local_cid_len i64, ks map] any
Parses & unprotects a Short Header (1-RTT) packet from off to the end of dgram.
build-transport-params = fn [orig_dcid bytes, init_scid bytes, is_server bool] bytes
record-rx-pn = fn [ranges block, pn i64] block
Merges received packet number pn into sorted ascending disjoint [lo, hi] inclusive intervals (retaining latest 16 ranges).
encode-ack-ranges = fn [ranges block] bytes
Encodes an RFC 9000 §19.3 ACK frame from ascending disjoint [lo, hi] inclusive PN intervals.
encode-ack-frame = fn [largest_pn i64] bytes
encode-crypto-frame = fn [offset i64, data bytes] bytes
encode-stream-frame = fn [stream_id i64, offset i64, data bytes, fin bool] bytes
parse-quic-frames = fn [buf bytes] any
Parses all QUIC frames inside a decrypted packet payload into a block of frame maps.
encode-h3-response-stream = fn [resp Message] bytes
Encodes HTTP/3 response headers + body into a contiguous HTTP/3 stream byte buffer (HEADERS + optional DATA).
decode-h3-request-stream = fn [stream_id i64, wire bytes] any
Decodes an HTTP/3 request stream buffer (HEADERS + optional DATA frames) into a Message.
ReassemblyBuf = struct { data bytes, ranges block, fin_known bool = ..., final_size i64 = ... }
Tracks out-of-order byte intervals without corrupting unreceived prefixes with zero bytes.
reasm-insert = fn [mut rb ReassemblyBuf, offset i64, chunk bytes, is_fin bool, max_bytes i64] bool
Inserts chunk at offset into rb (rejecting offsets exceeding max_bytes), merging contiguous [lo, hi] intervals.
reasm-contiguous-len = fn [rb ReassemblyBuf] i64
Returns the contiguous number of bytes received starting strictly at offset 0.
reasm-complete? = fn [rb ReassemblyBuf] bool
Returns true iff FIN has arrived and all bytes [0..final_size] are contiguously present.
serve-udp = fn [sock i64, get_ident_fn any, handler any, max_requests i64] i64
Serves HTTP/3 over QUIC v1 on bound UDP socket sock (net/udp-bind) with contiguous interval reassembly,
multi-packet PQC Initial handshakes, RFC 9000 PN reconstruction, multi-range ACKs, cwnd, and 25ms PTO retransmission.
request = fn [host str, port i64, method str, path str, headers map[str], body bytes] any
Performs a complete pure-Veko HTTP/3 over QUIC v1 request (Initial ClientHello -> Handshake Finished -> 1-RTT QPACK HEADERS/DATA -> Message response).
Supports WAN DNS resolution, '0.0.0.0' socket binding, out-of-order ReassemblyBuf, RFC 9000 PN reconstruction, multi-range ACKs, and 25ms PTO retransmission.