Expand description
Sans-io, strict HTTP/1.1 parser and serializer (RFC 9112) for simoom.
parse_request/RequestParser: zero-copy request heads (borrowed slices, caller-owned header storage, no allocation), resumable over partial input, strict per RFC 9112.parse_response: the same for responses (client side and test tools).BodyDecoder: Content-Length, chunked (strict grammar, capped extensions, trailers) and close-delimited bodies, incremental and zero-copy.- [
write]: cachedDate, pre-serialized heads, a head writer, the chunked encoder. h2c: the HTTP/2 preface and theUpgrade: h2crequest.ws(featurewebsocket): the RFC 6455 handshake and frame codec.
Pipelining: a parsed head reports its length, the body decoder reports what it consumed, and the next request starts right after; nothing is buffered inside the codec except while a trailer section is incomplete.
Modules§
- h2c
- HTTP/2 over cleartext: prior-knowledge preface detection and the
Upgrade: h2crequest (RFC 9113 §3.3, RFC 7540 §3.2). - write
- 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 onewritev: head, body, and for chunked bodies the chunk header and the CRLF around each piece. - ws
- WebSocket (RFC 6455): handshake validation and a sans-io frame codec.
Structs§
- Body
Decoder - Decodes one message body from successive pieces of input.
- Header
- A header field: borrowed name and value (OWS trimmed).
- Limits
- Parser limits (plan §7.1). Exceeding one gives a specific
Error. - Request
- A parsed request head. Everything borrows from the receive buffer (
'b) and the header storage ('h). - Request
Parser - Incremental request-head parsing for one connection: remembers how far the input was scanned, so a head that trickles in is fully parsed only once the empty line (or a limit) arrives. Eight bytes of state; reset automatically after each complete head or error.
- Response
- A parsed response head.
Enums§
- Body
Event - One step of body decoding.
- Error
- Why a message was refused. Every error means the connection must close after the error response (if any) is sent.
- Framing
- How the message body is delimited (RFC 9112 §6.3).
- Status
- Result of parsing input that may be incomplete.
- Target
Form - The form of a request target (RFC 9112 §3.2).
- Version
- The HTTP version of a message.
Constants§
- EMPTY_
HEADER - An empty header, to initialise header storage:
[EMPTY_HEADER; 100].
Functions§
- base64_
decode - Decodes padded standard base64 into
out; false (andoutunchanged) if it is not canonical base64. - base64_
encode - Appends the padded standard base64 encoding of
inputtoout. - base64url_
decode - Decodes unpadded base64url (as in
HTTP2-Settings) intoout; false (andoutunchanged) if it is not canonical. - has_
token - True if the comma-separated list
valuecontainstoken(case-insensitive), as inhas_token(connection_value, b"close"). - parse_
request - Parses a whole request head from the start of
bufintohs. - parse_
response - Parses a response head.
request_methoddecides the framing of HEAD and CONNECT replies. A 1xx head is returned like any other; read the next head after it. - parse_
trailers - Parses a trailer section as returned by
BodyEvent::End: field lines followed by the empty line, or nothing.