Skip to main content

Module http1

Module http1 

Source
Expand description

A hand-rolled HTTP/1.1 engine — no framework dependency, the same style as crates/monitor/src/server.rs and the accept loops of crates/coap-bridge/crates/websocket-bridge, extended to what those two don’t need: request/response bodies beyond one read() call, chunked Transfer-Encoding (RFC 7230 §4.1) on the request side, keep-alive (RFC 7230 §6.3), and a Content-Length DoS cap.

Scope: reads one request at a time off a blocking Read + Write stream, and writes one response. A caller loops read_request / write_response on the same connection for keep-alive; closes the stream (or a request/response that named Connection: close) ends it. Response bodies are always sent as Content-Length — every body this daemon serves (XML, WSDL, a SOAP fault) is fully materialized before it is sent, so there is no reason to chunk the output; only an inbound request body may arrive chunked, from a client library that does not know its body’s length up front.

Structs§

Request
A parsed HTTP/1.x request.
Response
A response to write.

Enums§

HttpError
Read/parse error.

Constants§

DEFAULT_MAX_BODY
Default cap on a request’s Content-Length / total chunked body size. DDS-WEB samples are typically small; a body larger than this is refused with 413 Payload Too Large before it is read into memory.
MAX_HEADER_BYTES
Cap on the request line + header block, read before any body handling — bounds a client that never sends a blank line.

Functions§

read_request
Reads one HTTP/1.x request off stream, decoding a chunked body if Transfer-Encoding: chunked is present, or reading exactly Content-Length bytes otherwise. Neither may exceed max_body.
write_response
Writes response to stream as Content-Length-framed HTTP/1.1, honoring keep_alive in the Connection header.