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.
- trailers (ext : Array (Chunk.ExtensionName × Option Chunk.ExtensionValue)) (count : Nat) : BodyState
Parse the trailer section after the last chunk one field at a time, tracking the number of trailer fields parsed.
- closeDelimited : BodyState
Parse body bytes until EOF (connection close).
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Std.Http.Protocol.H1.Reader.instBEqBodyState.beq (Std.Http.Protocol.H1.Reader.BodyState.fixed a) (Std.Http.Protocol.H1.Reader.BodyState.fixed b) = (a == b)
- Std.Http.Protocol.H1.Reader.instBEqBodyState.beq Std.Http.Protocol.H1.Reader.BodyState.chunkedSize Std.Http.Protocol.H1.Reader.BodyState.chunkedSize = true
- Std.Http.Protocol.H1.Reader.instBEqBodyState.beq (Std.Http.Protocol.H1.Reader.BodyState.chunkedBody a a_1) (Std.Http.Protocol.H1.Reader.BodyState.chunkedBody b b_1) = (a == b && a_1 == b_1)
- Std.Http.Protocol.H1.Reader.instBEqBodyState.beq (Std.Http.Protocol.H1.Reader.BodyState.trailers a a_1) (Std.Http.Protocol.H1.Reader.BodyState.trailers b b_1) = (a == b && a_1 == b_1)
- Std.Http.Protocol.H1.Reader.instBEqBodyState.beq Std.Http.Protocol.H1.Reader.BodyState.closeDelimited Std.Http.Protocol.H1.Reader.BodyState.closeDelimited = true
- Std.Http.Protocol.H1.Reader.instBEqBodyState.beq x✝¹ x✝ = false
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, or failed, and cannot process more data.
Instances For
Equations
Equations
- Std.Http.Protocol.H1.Reader.instBEqState.beq Std.Http.Protocol.H1.Reader.State.needStartLine Std.Http.Protocol.H1.Reader.State.needStartLine = true
- Std.Http.Protocol.H1.Reader.instBEqState.beq (Std.Http.Protocol.H1.Reader.State.needHeader a) (Std.Http.Protocol.H1.Reader.State.needHeader b) = (a == b)
- Std.Http.Protocol.H1.Reader.instBEqState.beq (Std.Http.Protocol.H1.Reader.State.readBody a) (Std.Http.Protocol.H1.Reader.State.readBody b) = (a == b)
- Std.Http.Protocol.H1.Reader.instBEqState.beq a.continue b.continue = Std.Http.Protocol.H1.Reader.instBEqState.beq a b
- Std.Http.Protocol.H1.Reader.instBEqState.beq Std.Http.Protocol.H1.Reader.State.pending Std.Http.Protocol.H1.Reader.State.pending = true
- Std.Http.Protocol.H1.Reader.instBEqState.beq Std.Http.Protocol.H1.Reader.State.complete Std.Http.Protocol.H1.Reader.State.complete = true
- Std.Http.Protocol.H1.Reader.instBEqState.beq Std.Http.Protocol.H1.Reader.State.closed Std.Http.Protocol.H1.Reader.State.closed = true
- Std.Http.Protocol.H1.Reader.instBEqState.beq x✝¹ x✝ = false
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. For a chunked body this includes the framing: chunk-size lines, the line break after each chunk's data, and the trailer section.
- headerBytesRead : Nat
Number of header bytes accumulated for the current message. Counts name + value bytes plus 4 bytes per line for
:and\r\n. - peerClosed : Bool
Set when the peer closed its side of the connection, so no further input bytes will arrive.
- inputStopped : Bool
Set when the machine stops taking input, as when it rejects
Expect: 100-continueor answers with an error and closes the connection. Input already buffered is still parsed.
Instances For
Whether no further input will be fed: the peer closed its side, or the machine stopped taking input.
Equations
- reader.noMoreInput = (reader.peerClosed || reader.inputStopped)
Instances For
Checks if the reader is in a closed state and cannot process more messages.
Equations
Instances For
Checks if the reader has completed parsing the current message.
Equations
- reader.isComplete = match reader.state with | Std.Http.Protocol.H1.Reader.State.complete => true | x => false
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.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Replaces the reader's input iterator with a new one.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Updates the message head being constructed.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Adds a header to the current message head.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Replaces the value of the last header named name in the current message head.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Marks the current message as complete and prepares for the next message.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Resets the reader to parse a new message on the same connection.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checks if more input is needed to continue parsing.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Transitions to the state for reading headers.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Transitions to the state for reading chunked transfer encoding.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checks if the connection should be kept alive for the next message.
Equations
- reader.shouldKeepAlive = reader.messageHead.shouldKeepAlive