Skip to main content

Crate simoom_http1

Crate simoom_http1 

Source
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]: cached Date, pre-serialized heads, a head writer, the chunked encoder.
  • h2c: the HTTP/2 preface and the Upgrade: h2c request.
  • ws (feature websocket): 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: h2c request (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 one writev: 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§

BodyDecoder
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).
RequestParser
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§

BodyEvent
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.
TargetForm
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 (and out unchanged) if it is not canonical base64.
base64_encode
Appends the padded standard base64 encoding of input to out.
base64url_decode
Decodes unpadded base64url (as in HTTP2-Settings) into out; false (and out unchanged) if it is not canonical.
has_token
True if the comma-separated list value contains token (case-insensitive), as in has_token(connection_value, b"close").
parse_request
Parses a whole request head from the start of buf into hs.
parse_response
Parses a response head. request_method decides 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.