FlexibleParser

Namespace: Glyph11.Parser.FlexibleParser

public static partial class FlexibleParser

A minimal-validation HTTP/1.1 header parser optimized for maximum throughput.

Methods

TryExtractFullHeader

public static bool TryExtractFullHeader(
    ref ReadOnlySequence<byte> input,
    BinaryRequest request,
    out int bytesReadCount)

Entry point that auto-dispatches based on segment layout. If the input is a single segment, delegates to TryExtractFullHeaderReadOnlyMemory. If multi-segment, checks for header completeness, linearizes via ToArray(), then parses.

Parameters:

ParameterTypeDescription
inputref ReadOnlySequence<byte>The input buffer to parse
requestBinaryRequestThe request object to populate
bytesReadCountout intNumber of bytes consumed on success

Returns: true if a complete header was parsed; false if the header is incomplete (waiting for more data).

Throws: HttpParseException for structurally unparseable input.


TryExtractFullHeaderReadOnlyMemory

public static bool TryExtractFullHeaderReadOnlyMemory(
    ref ReadOnlyMemory<byte> input,
    BinaryRequest request,
    out int bytesReadCount)

Single-segment parser operating on contiguous memory. Zero-allocation — all parsed fields are ReadOnlyMemory<byte> slices into the input.

Parameters:

ParameterTypeDescription
inputref ReadOnlyMemory<byte>Contiguous input buffer
requestBinaryRequestThe request object to populate
bytesReadCountout intNumber of bytes consumed on success

Returns: true if a complete header was parsed; false if the header is incomplete.

Throws: HttpParseException for structurally unparseable input.