HttpReader Type

Constructors

Constructor Description

HttpReader(transport, pipe, cancellationToken)

Full Usage: HttpReader(transport, pipe, cancellationToken)

Parameters:
Returns: HttpReader
transport : ITransport
pipe : Pipe
cancellationToken : CancellationToken
Returns: HttpReader

Instance members

Instance member Description

this.cancelPendingReads ()

Full Usage: this.cancelPendingReads ()

this.init ()

Full Usage: this.init ()

this.isDirty

Full Usage: this.isDirty

Returns: bool
Returns: bool

this.readHeaders ()

Full Usage: this.readHeaders ()

Returns: SocketOp<List<string * string>>
 Read all headers from the stream, returning a list of (name, value) pairs.
 Names are returned lowercase. Optimized to avoid the per-header string
 allocations performed by the previous string-based parser:
  - Reads each header line directly into the byte buffer (no UTF8.GetString of the whole line).
  - Uses byte-span scanning for ':' and whitespace trimming.
  - Returns interned lowercase strings for well-known header names (zero allocation for name).
  - For unknown names, lowercases ASCII in a scratch buffer and allocates exactly one string.
  - Allocates exactly one string for the value.
Returns: SocketOp<List<string * string>>

this.readHeadersInto headers

Full Usage: this.readHeadersInto headers

Parameters:
    headers : List<string * string>

Returns: SocketOp<List<string * string>>

Read all headers into the supplied list. The caller is responsible for clearing the list before the call. This avoids allocating a new List per request when the caller is reusing a per-connection list.

headers : List<string * string>
Returns: SocketOp<List<string * string>>

this.readLine ()

Full Usage: this.readLine ()

Returns: SocketOp<string>

Read a line from the stream, calling UTF8.toString on the bytes before the EOL marker

Returns: SocketOp<string>

this.readMoreData ()

Full Usage: this.readMoreData ()

Returns: ValueTask<Result<unit, Error>>
Returns: ValueTask<Result<unit, Error>>

this.readPostData bytes select

Full Usage: this.readPostData bytes select

Parameters:
Returns: Task<unit>

Read the post data from the stream, given the number of bytes that makes up the post data.

bytes : int
select : ReadOnlyMemory<byte> -> int -> unit
Returns: Task<unit>

this.readRequestLine ()

Full Usage: this.readRequestLine ()

Returns: SocketOp<string * string * string * string>
 Read the HTTP request line directly from the byte buffer and decompose it
 into (method, path, rawQuery, version).

 Allocation profile vs. the previous `readLine` + `parseUrl` pipeline:
   - method: 0 allocations on the common path (interned via `KnownMethods.tryMatch`)
   - version: 0 allocations on the common path (interned via `KnownVersions.tryMatch`)
   - path: 1 string allocation (sliced directly from `readLineBuffer`)
   - rawQuery: 1 string allocation only when '?' is present, otherwise `String.Empty`
 Previously the same data cost: 1 full-line UTF-8 string + 4 `Substring` allocations.
Returns: SocketOp<string * string * string * string>

this.readUntilPattern marker select

Full Usage: this.readUntilPattern marker select

Parameters:
Returns: SocketOp<int64>

Read the passed stream into buff until the marker (e.g. CRLF) is reached and returns the number of bytes consumed before the marker. This is now a thin adapter over `scanMarker`: since `scanMarker` no longer returns `NeedMore` to its caller (the internal async fallback pumps until the scan is terminal), we just translate `ScanResult` into an `int64`. When `scanMarker` completes synchronously \u2014 the common case for HTTP/1.1 keep-alive where the next request's headers arrive in a single `recv()` \u2014 the entire `readUntilPattern` call also completes synchronously without allocating a state-machine box.

marker : byte[]
select : SelectFunction
Returns: SocketOp<int64>

this.scanMarker marker select

Full Usage: this.scanMarker marker select

Parameters:
Returns: ValueTask<Result<ScanResult, Error>>

Iterates over a BufferSegment list looking for a marker, data before the marker is sent to the function select. Returns synchronously when the marker is already present in the buffered data \u2014 the common case for HTTP/1.1 keep-alive where the next request's headers typically arrive in a single recv().

marker : byte[]
select : SelectFunction
Returns: ValueTask<Result<ScanResult, Error>>

this.skip n

Full Usage: this.skip n

Parameters:
    n : int64

Returns: Task<ScanResult>
n : int64
Returns: Task<ScanResult>

this.stop ()

Full Usage: this.stop ()