Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Http.Http3Server

Feature notes: HTTPS application layer notes (HTTP/1.1, h2, h3)

Classes, interfaces and records

interfaceiHttp3ServerTransport

What tHttp3ServerConn needs from an authenticated QUIC connection. TsmHTTPSv3 supplies its own; implement it only to drive the engine from your own QUIC host. The engine calls it from inside its own methods. OpenStream opens a server unidirectional stream (ID mod 4 = 3) or returns False while the peer's stream limit blocks it; the engine retries on a later Pump. SendCapacity is how many bytes Send may take now on that stream; 0 pauses that stream until a later Pump (never block). Send must take the whole range together with the FIN flag and may keep aData, which neither side may modify. Consume gives the peer receive credit for aCount bytes the engine has finished with; credit for bytes of a reset stream that never reached Receive is yours to return. ResetSend, StopReceive and Close abort a stream's sending, ask the peer to stop sending, or close the connection, with an HTTP/3 error code.

function OpenStream(aUnidirectional: Boolean; out aStreamID: UInt64): Boolean; function SendCapacity(aStreamID: UInt64): Integer; procedure Send(aStreamID: UInt64; const aData: TBytes; aOffset, aCount: Integer; aFin: Boolean); procedure Consume(aStreamID, aCount: UInt64); procedure ResetSend(aStreamID, aErrorCode: UInt64); procedure StopReceive(aStreamID, aErrorCode: UInt64); procedure Close(aErrorCode: UInt64; const aReason: string);

interfaceiHttp3ServerTransportEarlyData

Optional; implement it on the iHttp3ServerTransport object when the connection may accept 0-RTT. Before a request is admitted to a streaming route, the engine answers 425 if EarlyDataWindowOpen is True (late 0-RTT data can still be accepted on the connection) or StreamHasEarlyData is True (the stream has received 0-RTT bytes, delivered yet or not). It does not change the request's EarlyData flag.

function EarlyDataWindowOpen: Boolean; function StreamHasEarlyData(aStreamID: UInt64): Boolean;

recordtHttp3ReceiveLimits

StreamAllowance, ConnectionAllowance, PeerUniAllowance: UInt64; GuaranteedReceiveReserve, ReceiveTerminal: Boolean;

interfaceiHttp3ServerTransportReceiveLimits

function TryGetReceiveLimits(aStreamID: UInt64; out aLimits: tHttp3ReceiveLimits): Boolean;

interfaceiHttp3ServerTransportStreamBudget

Optional cumulative client-bidi budget. The host reserves records for all granted IDs, including skipped IDs and pending unidirectional credit.

function GetStreamBudget(out aOpened, aGrant: UInt64; out aMetadata, aCeiling: Integer): Boolean; function IncreaseStreamBudget(aGrant: UInt64): Boolean; procedure RequestDrain;

recordtHttp3ServerLimits

SendWindowBytes: Integer; MaxHeaderBlockBytes, MaxFieldSectionBytes, MaxBufferedSendBytes: Integer; MaxActiveRequests, MaxRequests, MaxPeerUniStreams: Integer; MinRequestBlockAgeMSec: Integer; MaxBodyBytes, MaxConnectionBodyBytes, MaxMemoryResponseBytes: Integer; MaxUnproductiveFrames: Integer; QpackTableCapacity, QpackBlockedStreams, MaxQpackBlockedBytes: Integer; MaxPushes, MaxActivePushes, MaxPushBufferedBytes, PushTimeoutMSec: Integer;
Deprecated - leave MaxPushes 0. Server push: no browser accepts it.
HeaderTimeoutMSec, RequestTimeoutMSec: Integer;

classtHttp3ServerConn

The HTTP/3 server engine for one QUIC connection. TsmHTTPSv3 creates and drives one per connection; use it directly only with your own QUIC host. Create it over your iHttp3ServerTransport and assign RequestHandler, which receives each complete request. With a Router, OnResolvedDispatch (if assigned) receives it instead, with the resolved handler; streaming routes (HTTP.txt section 24) also need Wake, OnWorkDeadline and iHttp3ServerTransportReceiveLimits, or they answer 503. Call Start when the handshake is authenticated with h3. Then report peer input in stream order with Receive or ReceiveEarly, and ResetReceived, StopReceived and TransportClosed as they happen; call Pump when the transport can send more, and WorkQueued when the time last reported by OnWorkDeadline (stTlsUtils.GetTickCount64 milliseconds, 0 for none) is due or Wake asks for it (Wake can be called on a worker thread and must only schedule that call). Without OnWorkDeadline, timeouts are checked only when you call in. Calls must come from one thread at a time. Handlers run inside the Receive or ReceiveEarly call that completed the request, with the whole body; they must not call back into this object. A failing response source resets only its own request. For a graceful close, see BeginDrain.

constructor Create(const aTransport: iHttp3ServerTransport; const aRemoteAddress: string); overload; constructor Create(const aTransport: iHttp3ServerTransport; const aRemoteAddress: string; const aLimits: tHttp3ServerLimits); overload; destructor Destroy; override; function ReleaseStream(aStreamID: UInt64): Boolean;
Called outside engine turns, after transport completion. False retains the record while QPACK, streaming or application output still owns it.
function RetainedStreamCount: Integer;
Delegates to Length, forwarding fStreams, and returns its result.
function RequestBlockCount: UInt64; procedure Start;
Call once, after the QUIC handshake is authenticated and ALPN chose h3. It opens the control and QPACK streams and starts the HeaderTimeoutMSec deadline for the client's SETTINGS. All input calls need Start first: hold accepted 0-RTT data until then and deliver it with ReceiveEarly.
procedure Pump; procedure WorkQueued; property RemoteAddress: string read fRemoteAddress write fRemoteAddress;
The owner refreshes the current validated address before observing input. A new stream snapshots it, so a request keeps its first path.
procedure ObserveReceive(aStreamID, aStartedMS: UInt64);
Optional: report a peer stream when any of its data first arrives, even out of order, before Receive can deliver it; aStartedMS is that moment in stTlsUtils.GetTickCount64 milliseconds. The header deadline then runs from it, so a gap at the start of a stream cannot stall it; without this call it starts at the first Receive. Report only streams the peer actually sent on; repeats are ignored.
procedure Receive(aStreamID: UInt64; const aData: TBytes; aFin: Boolean); procedure ReceiveEarly(aStreamID: UInt64; const aData: TBytes; aFin: Boolean);
Same as Receive, for bytes that arrived as accepted 0-RTT data; pass each chunk to Receive or ReceiveEarly according to how it arrived. Full description »
procedure ResetReceived(aStreamID, aErrorCode: UInt64); procedure StopReceived(aStreamID, aErrorCode: UInt64); procedure TransportClosed(aErrorCode: UInt64); procedure BeginDrain(aFirstRejectedStreamID: UInt64);
Graceful shutdown: sends GOAWAY with aFirstRejectedStreamID, the lowest request stream ID that will not be processed, and refuses each request at or above it, now or later, with H3_REQUEST_REJECTED (the client may send those again elsewhere). Full description »
property Ready: Boolean read GetReady; property Closed: Boolean read fClosed; property Draining: Boolean read fDraining; property Drained: Boolean read GetDrained; property SettingsReceived: Boolean read fSettingsReceived; property QpackBlockedCount: Integer read fQpackBlockedCount;
Dynamic QPACK diagnostics: QpackBlockedCount is the number of request streams waiting for encoder-table entries that have not arrived yet; QpackBytesHeld is the encoded header and later stream bytes held for them, bounded by MaxQpackBlockedBytes. Both stay 0 unless QpackTableCapacity and QpackBlockedStreams are configured.
property QpackBytesHeld: Integer read fQpackBlockedBytes; property PeerSettings: tHttp3Settings read fPeerSettings; property ActiveRequests: Integer read fActiveRequests; property ActivePushes: Integer read fActivePushes;
Deprecated - server push only.
property PushBytesHeld: Integer read fPushBytes;
Deprecated - server push only.
property QueuedBytes: Integer read GetQueuedBytes;
Diagnostics: QueuedBytes - output bytes not yet handed to the transport; OutgoingTrailerBytesHeld and TerminalSendBytesHeld - response trailers waiting to be sent, as fields and encoded, TerminalSendParts their count; BodyBytesHeld - request-body memory (buffered bodies and streaming buffers), bounded by MaxConnectionBodyBytes.
property OutgoingTrailerBytesHeld: Int64 read fOutgoingTrailerBytes; property TerminalSendBytesHeld: Integer read fTerminalRetainedBytes; property TerminalSendParts: Integer read fTerminalParts; property BodyBytesHeld: Integer read fHeldBodyBytes; property TrailerBytesHeld: Int64 read fHeldTrailerBytes;
Diagnostics: TrailerBytesHeld - received request trailers held until their request has been handed over; MemoryResponseBytesHeld - memory-backed response bodies still being sent (file and stream sources are not counted), bounded by MaxMemoryResponseBytes.
property MemoryResponseBytesHeld: Integer read fMemoryResponseBytes; property Session: iHttpSession read fSession write fSession; property ConnectionInfo: iHttpConnectionInfo read fConnectionInfo write fConnectionInfo; property RequestHandler: tHttpRequestEvent read fRequestHandler write fRequestHandler; property Router: iHttpRouter read fRouter write fRouter; property SessionProvider: iHttpSessionProvider read fSessionProvider write fSessionProvider; property Wake: iHttpServerWake read fWake write fWake; property OnWorkDeadline: tHttp3DeadlineEvent read fWorkDeadline write fWorkDeadline; property OnResolvedDispatch: tHttp3ResolvedDispatchEvent read fResolvedHandler write fResolvedHandler; property StreamingWindowBytes: UInt64 read fStreamingWindows;
Diagnostic for streaming routes: the receive window (bytes the client may still send) summed over this connection's request streams, as counted when a streaming request is admitted. Full description »
property DeadlineScanWork: Int64 read fDeadlineScanWork;
Diagnostic: the cumulative input-deadline scan work, one unit per stream examined in a deadline pass. The pass runs at most once per tick, so this grows with elapsed ticks, not with the number of frame pieces or blocked streams processed in a tick.
property BodyCharge: tHttp3ChargeMethod read fBodyCharge write fBodyCharge;
Optional memory budget shared with other connections (TsmHTTPSv3 uses it for TotalBodyBytes and TotalResponseBytes). Full description »
property BodyRelease: tHttp3ReleaseMethod read fBodyRelease write fBodyRelease; property ResponseCharge: tHttp3ChargeMethod read fResponseCharge write fResponseCharge; property ResponseRelease: tHttp3ReleaseMethod read fResponseRelease write fResponseRelease;

Types (enumerations, sets, aliases)

proctHttp3ResolvedDispatchEvent

  tHttp3ResolvedDispatchEvent = procedure(Sender: TObject; const aRequest: iHttpRequest;
    const aResponse: iHttpResponse; const aHandler: iHttpRequestHandler) of object;

proctHttp3DeadlineEvent

  tHttp3DeadlineEvent = procedure(aDeadline: UInt64) of object;

proctHttp3ChargeMethod

  tHttp3ChargeMethod = function (aBytes: Integer): Boolean of object;

proctHttp3ReleaseMethod

  tHttp3ReleaseMethod = procedure (aBytes: Integer) of object;

Routines