Expand description
Serialization: the cached Date, pre-serialized heads, a head writer and the chunked
encoder. Everything writes into caller-owned buffers or returns small stack values, so a
response can go out as one writev: head, body, and for chunked bodies the chunk header and
the CRLF around each piece.
Structs§
- Chunk
Header - A chunk header,
<hex length>\r\n, on the stack. - Date
Cache - The
Datevalue, formatted once per second. The caller owns the clock: callupdatewith the current Unix time, typically once per loop tick. - Head
Writer - Writes a message head into a caller-owned buffer (reuse it to avoid allocation). Field names
and values are validated, so a value cannot split the response; framing goes through
content_lengthandchunkedonly. - Static
Head - A response serialized once, with a
Dateslot patched at most once a second: the fast path for fixed replies. The body (possibly empty) follows the head in the same buffer, so the whole reply is one slice.
Constants§
- CONTINUE
HTTP/1.1 100 Continuewith its empty line.- CRLF
- The CRLF that ends each chunk’s data.
- LAST_
CHUNK - The last chunk with no trailers.
Functions§
- http_
date - The IMF-fixdate for a Unix time, e.g.
Sun, 06 Nov 1994 08:49:37 GMT(RFC 9110 §5.6.7). - reason
- The reason phrase for a status code (empty for codes without one).
- write_
chunk - Appends one chunk (header, data, CRLF). Empty data writes nothing, since an empty chunk would end the body.
- write_
last_ chunk - Appends the last chunk, the trailer fields and the final empty line.