Maximum number of headers per request. Requests with more headers are rejected to prevent denial-of-service.
Equations
Instances For
Parse an HTTP version string like "HTTP/1.1". $$\text{parseHttpVersion} : \text{String} \to \text{Option}(\text{HttpVersion})$$
Equations
- One or more equations did not get rendered due to their size.
Instances For
Parse a request line like "GET /path?query HTTP/1.1".
Returns (method, rawPath, rawQuery, version) or none if malformed.
$$\text{parseRequestLine} : \text{String} \to \text{Option}(\text{Method} \times \text{String} \times \text{String} \times \text{HttpVersion})$$
Equations
- One or more equations did not get rendered due to their size.
Instances For
Parse a single header line like "Content-Type: text/html".
Returns none if the line doesn't contain a colon.
$$\text{parseHeaderLine} : \text{String} \to \text{Option}(\text{Header})$$
Equations
- One or more equations did not get rendered due to their size.
Instances For
Parse header lines into a list of headers. $$\text{parseHeaders} : \text{List}(\text{String}) \to \text{RequestHeaders}$$
Equations
Instances For
Read all header lines from a buffered reader until an empty line.
Returns the request line and header lines.
Uses O(1) cons + single reverse instead of O(n) append.
Bounded by maxHeaders to prevent DoS.
$$\text{recvHeaders} : \text{RecvBuffer} \to \text{IO}(\text{String} \times \text{List}(\text{String}))$$
Equations
- One or more equations did not get rendered due to their size.
Instances For
Header count bound: The header count returned by recvHeaders is
bounded by maxHeaders. The while loop checks count >= maxHeaders
before each cons, ensuring at most maxHeaders elements are added.
Axiom-dependent on IO monad execution semantics — the loop guard is
checked before each FFI.recvBufReadLine call, but the proof cannot
be discharged because recvHeaders uses do-notation over IO with
mutable state (let mut), which is opaque to the kernel.
$$\forall\, \text{rl}\; \text{hdrs},\; \text{recvHeaders}(\text{buf}) = \text{pure}(\text{rl}, \text{hdrs}) \implies \text{hdrs.length} \leq \text{maxHeaders}$$
Parse a full HTTP request from a buffered reader.
Returns none if the request line is malformed or the connection is closed.
$$\text{parseRequest} : \text{RecvBuffer} \to \text{SockAddr} \to \text{IO}(\text{Option}(\text{Request}))$$
Equations
- One or more equations did not get rendered due to their size.