codec/http1
lib/codec/http1.vklib/codec/http1.vk
Pure-Veko HTTP/1.1 wire codec and parse-block message adapter.
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
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 ]
encode-response = fn [status i64, reason str, headers map, body bytes] any
Encodes an HTTP/1.1 response wire frame.
decode-response = fn [raw bytes] any
Decodes an HTTP/1.1 response message into { version, status, reason, headers, body, consumed }.
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).
decode-request = fn [raw bytes] any
Decodes an HTTP/1.1 request message into { method, target, version, headers, body, consumed }.
request-to-block = fn [req map] block
Converts a decoded request into [ .req method target version headers body ] for parse-block.
response-to-block = fn [resp map] block
Converts a decoded response into [ .resp version status reason headers body ] for parse-block.