HTTP/1.1 Reader #
This module defines the reader state machine for parsing incoming HTTP/1.1 messages. It tracks the parsing state including start line, headers, and body handling for both fixed-length and chunked transfer encodings.
The body-framing sub-state of the Reader state machine.
- fixed
(remaining : Nat)
: BodyState
Parse fixed-length body bytes, tracking the number of bytes remaining.
- chunkedSize : BodyState
Parse the next chunk-size line in chunked transfer encoding.
- chunkedBody
(ext : Array (Chunk.ExtensionName × Option Chunk.ExtensionValue))
(remaining : Nat)
: BodyState
Parse chunk data for the current chunk.
- closeDelimited : BodyState
Parse body bytes until EOF (connection close).
Instances For
Instances For
The state of the Reader state machine.
- needStartLine
{dir : Direction}
: State dir
Initial state waiting for HTTP start line.
- needHeader
{dir : Direction}
: Nat → State dir
State waiting for HTTP headers, tracking number of headers parsed.
- readBody
{dir : Direction}
: BodyState → State dir
Unified body-reading state.
- continue
{dir : Direction}
: State dir → State dir
Paused waiting for a
canContinuedecision, carrying the next state. - pending
{dir : Direction}
: State dir
State waiting to be able to read new data.
- complete
{dir : Direction}
: State dir
State that it completed a single request or response and can go to the next one
- closed
{dir : Direction}
: State dir
State that it has completed and cannot process more data.
- failed
{dir : Direction}
(error : Error)
: State dir
The input is malformed.
Instances For
Manages the reading state of the HTTP parsing and processing machine.
- state : State dir
The current state of the machine.
- input : ByteArray.Iterator
The input byte array.
- messageHead : Message.Head dir
The incoming message head.
- messageCount : Nat
Count of messages that this connection has already parsed.
- bodyBytesRead : Nat
Number of body bytes read for the current message.
- headerBytesRead : Nat
Number of header bytes accumulated for the current message. Counts name + value bytes plus 4 bytes per line for
:and\r\n. - noMoreInput : Bool
Set when no further input bytes will arrive (the remote end has closed the connection).
Instances For
Checks if the reader is in a closed state and cannot process more messages.
Instances For
Checks if the reader has completed parsing the current message.
Instances For
Checks if the reader has encountered an error.
Instances For
Feeds new data into the reader's input buffer. If the current input is exhausted, replaces it; otherwise compacts the buffer by discarding already-parsed bytes before appending.
Instances For
Replaces the reader's input iterator with a new one.
Instances For
Updates the message head being constructed.
Instances For
Adds a header to the current message head.
Instances For
Closes the reader, transitioning to the closed state.
Instances For
Marks the current message as complete and prepares for the next message.
Instances For
Resets the reader to parse a new message on the same connection.
Instances For
Checks if more input is needed to continue parsing.
Instances For
Gets the number of bytes remaining in the input buffer.
Instances For
Transitions to the state for reading headers.
Instances For
Transitions to the state for reading chunked transfer encoding.
Instances For
Marks that no more input will be provided (connection closed).
Instances For
Checks if the connection should be kept alive for the next message.