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

codec/http1

lib/codec/http1.vk

lib/codec/http1.vk Pure-Veko HTTP/1.1 wire codec and parse-block message adapter.

signature
encode-request = fn [method str, target str, headers map, body bytes] any

Encodes an HTTP/1.1 request wire frame (METHOD TARGET HTTP/1.1\r\n...).

Executable Example
veko
use [h1 = codec/http1]
req = h1/encode-request 'GET' '/health' { Host = 'api.local' } (bytes/with-cap 0)
dec = h1/decode-request req
if dec.method != 'GET' or dec.target != '/health' [ err 'http1 roundtrip' ] else [ .ok ]
signature
encode-response = fn [status i64, reason str, headers map, body bytes] any

Encodes an HTTP/1.1 response wire frame.

signature
decode-response = fn [raw bytes] any

Decodes an HTTP/1.1 response message into { version, status, reason, headers, body, consumed }.

signature
decode-response-head = fn [raw bytes] any

Decodes an HTTP/1.1 HEAD response (status + headers with zero body bytes on the wire, preserving Content-Length).

signature
decode-request = fn [raw bytes] any

Decodes an HTTP/1.1 request message into { method, target, version, headers, body, consumed }.

signature
request-to-block = fn [req map] block

Converts a decoded request into [ .req method target version headers body ] for parse-block.

signature
response-to-block = fn [resp map] block

Converts a decoded response into [ .resp version status reason headers body ] for parse-block.