Expand description
HTTP/1.1 message syntax (RFC 9112): heads, framing, chunked bodies.
A head is decoded whole or not at all: decode_request and
decode_response first find the empty line that ends it, within
Limits::max_head_bytes, and only then parse, so every proper prefix of
a valid head is DecodeError::Incomplete and a head that never ends is
DecodeError::TooLarge once the cap’s worth of octets has been searched.
The body’s framing is decided from the head by request_framing and
response_framing (RFC 9112 §6.3); a chunked body is decoded step by
step by ChunkedDecoder, which hands out slices of the caller’s buffer.
Structs§
- Chunked
Decoder - The state of a chunked body decode (RFC 9112 §7.1).
- Request
Head - A decoded request head, borrowing from the input.
- Response
Head - A decoded response head, borrowing from the input.
Enums§
Functions§
- connection_
has - Whether the
Connectionfield listsoption, ignoring ASCII case (RFC 9110 §7.6.1). - content_
length - The value of
Content-Length, if present: a list of equal values is one value (RFC 9110 §8.6). - decode_
request - Decodes a request head. Returns it and the octets it used, the empty line included; the body, if any, starts there.
- decode_
response - Decodes a response head. Returns it and the octets it used.
- encode_
chunk - Writes one chunk: the size in uppercase hex, CRLF, the data, CRLF. Empty data writes nothing, because a zero-size chunk is the last chunk.
- encode_
last_ chunk - Writes the last chunk and the trailer section.
- encode_
request_ head - Writes an
HTTP/1.1request head, the empty line included. - encode_
response_ head - Writes a response head with version
HTTP/1.<minor>, the empty line included. - request_
framing - The framing of a request body (RFC 9112 §6.3 rules 3 to 7).
- response_
framing - The framing of a response body (RFC 9112 §6.3 rules 1 to 7), given the method of the request it answers.