Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Http.Http3Client

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

Classes, interfaces and records

interfaceiHttp3ClientTransport

What tHttp3ClientConn needs from an authenticated QUIC connection. tHttp3QuicClient implements it over tQuicClient; implement it yourself only to run the engine over another QUIC stack. The engine calls it from inside its own methods. OpenStream opens a client stream (request: ID mod 4 = 0; unidirectional: ID mod 4 = 2) or returns False (aStreamID 0) while the peer's stream limit blocks it; StartRequest then raises. SendCapacity is how many bytes Send may take now on that stream (queue and flow-control room, not datagram space); 0 pauses that stream until a later Pump. 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. In turn, call Start, then Receive (in stream order), ResetReceived, StopReceived and TransportClosed as events arrive, and Pump after each batch of input and whenever send room grows.

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);

interfaceiHttp3ClientObserver

Implement this to receive responses. Callbacks run inside the call that caused them (usually Pump; Cancel reports RequestFailed before it returns) and must not call back into the adapter or engine, which raises: note what you need and act after the call returns. Per request: ResponseHeaders (aInformational True for each 1xx), ResponseData chunks, ResponseTrailers if the response has them, then ResponseComplete; or RequestFailed at any point. Exactly one of ResponseComplete and RequestFailed ends each request. aRetryable True means the server did not process the request, so it is safe to send again (after GOAWAY, on a new connection). ConnectionFailed comes last, after RequestFailed for every unfinished request; the connection cannot be used again. You may keep the arrays but must not modify them. Received body bytes withhold flow-control credit from the server until you call ReleaseBody(aStreamID, byte count) after the callback (still allowed once the request has ended); unreleased bytes stall the response and count against MaxHeldBodyBytes.

procedure ResponseHeaders(aStreamID: UInt64; const aHeaders: tQpackFields; aInformational: Boolean); procedure ResponseData(aStreamID: UInt64; const aData: TBytes); procedure ResponseTrailers(aStreamID: UInt64; const aHeaders: tQpackFields); procedure ResponseComplete(aStreamID: UInt64); procedure RequestFailed(aStreamID, aErrorCode: UInt64; aRetryable: Boolean); procedure ConnectionFailed(aErrorCode: UInt64; const aReason: string);

interfaceiHttp3PushObserver

Implement on the iHttp3ClientObserver object to accept server push; it is required, and used, only when tHttp3ClientLimits.MaxPushes > 0. PushPromised gets the validated promised request; return True to accept it, False to cancel it. The other callbacks mirror the response callbacks, keyed by push ID; a pushed response never becomes an ordinary response, cache entry or Alt-Svc record. Same rules as for iHttp3ClientObserver; release body bytes with ReleasePushBody.

function PushPromised(aRequestID, aPushID: UInt64; const aFields: tQpackFields): Boolean; procedure PushHeaders(aPushID: UInt64; const aFields: tQpackFields; aInformational: Boolean); procedure PushData(aPushID: UInt64; const aData: TBytes); procedure PushTrailers(aPushID: UInt64; const aFields: tQpackFields); procedure PushComplete(aPushID: UInt64); procedure PushFailed(aPushID, aErrorCode: UInt64);

recordtHttp3ClientLimits

MaxHeaderBlockBytes, MaxFieldSectionBytes, MaxBufferedSendBytes: Integer; MaxActiveRequests, MaxRequests, MaxPeerUniStreams, MaxHeldBodyBytes: Integer; MaxUnproductiveFrames: Integer; QpackTableCapacity, QpackBlockedStreams, MaxQpackBlockedBytes: Integer; MaxPushes, MaxActivePushes, MaxPushBufferedBytes, PushTimeoutMSec: Integer;
Deprecated - leave MaxPushes 0. Server push only.

classtHttp3ClientConn

constructor Create(const aTransport: iHttp3ClientTransport; const aObserver: iHttp3ClientObserver); overload; constructor Create(const aTransport: iHttp3ClientTransport; const aObserver: iHttp3ClientObserver; const aLimits: tHttp3ClientLimits); overload; destructor Destroy; override; procedure Start;
For a standalone engine; tHttp3QuicClient calls these itself. Call Start once the transport is authenticated with ALPN h3: it opens the control and QPACK streams, and Ready turns True when they are open. Full description »
procedure StartEarly(const aRememberedSettings: tHttp3Settings); procedure RejectEarlyData; procedure Pump; function StartRequest(const aMethod, aScheme, aAuthority, aPath: string; const aHeaders: tQpackFields; const aBody: TBytes): UInt64; overload;
Starts a request once Ready and returns its stream ID (0 is valid). Method, scheme (https or http), authority and an origin-form path ('*' for OPTIONS) are ASCII; aHeaders holds the other fields, with lowercase names and values as HTTP octets, and no connection-specific fields. Full description »
function StartRequest(const aMethod, aScheme, aAuthority, aPath: string; const aHeaders: tQpackFields; const aBody: TBytes; aEndStream: Boolean): UInt64; overload;
Delegates to StartRequest, passing 7 argument(s), and returns its result. » member page
function RequestBodyOpen(aStreamID: UInt64): Boolean;
For a body left open by StartRequest(..., False): True while TrySendBody and TrySendTrailers are allowed. False: unknown ID, body already finished, or the request failed, was cancelled or was stopped by the server - stop producing.
function RequestBodyPending(aStreamID: UInt64): Boolean;
True until the request's last body byte and FIN have been handed to the transport (not necessarily delivered yet). False also when the upload was stopped or failed, or the ID is unknown.
function RequestBodyCapacity(aStreamID: UInt64): Integer;
RequestBodyCapacity is the largest chunk TrySendBody would take now, DATA framing excluded, limited by the send queue and any remaining declared Content-Length. Full description »
function TrySendBody(aStreamID: UInt64; const aData: TBytes; aEndStream: Boolean): Boolean; function TrySendTrailers(aStreamID: UInt64; const aTrailers: tHttpHeaders): Boolean;
Ends an open body with request trailers; aTrailers is copied and stays yours. True: the body is closed as by a final TrySendBody, and the trailers are queued to follow all queued DATA, then FIN; an empty collection just ends the body. Full description »
procedure Receive(aStreamID: UInt64; const aData: TBytes; aFin: Boolean); procedure ResetReceived(aStreamID, aErrorCode: UInt64); procedure StopReceived(aStreamID, aErrorCode: UInt64); procedure TransportClosed(aErrorCode: UInt64); procedure ReleaseBody(aStreamID, aCount: UInt64); procedure ReleasePushBody(aPushID, aCount: UInt64);
Deprecated - server push only.
procedure CancelPush(aPushID: UInt64);
Deprecated - server push only.
procedure BeginPushDrain(aFirstRejectedPushID: UInt64);
Deprecated - server push only.
function NextPushDeadline(out aTickMS: UInt64): Boolean;
Deprecated - server push only.
procedure Cancel(aStreamID: UInt64); property Ready: Boolean read GetReady; property Closed: Boolean read fClosed; property SettingsReceived: Boolean read fSettingsReceived; property QpackBlockedCount: Integer read fQpackBlockedCount;
Dynamic QPACK diagnostics: QpackBlockedCount is the number of response 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 TrailerBytesHeld: Int64 read fHeldTrailerBytes;
Diagnostics, in bytes: TrailerBytesHeld - received response trailers held until their FIN is validated; QueuedBytes - output not yet handed to the transport; OutgoingTrailerBytesHeld and TerminalSendBytesHeld - request trailers waiting to be sent, as fields and encoded.
property QueuedBytes: Integer read GetQueuedBytes; property OutgoingTrailerBytesHeld: Int64 read fOutgoingTrailerBytes; property TerminalSendBytesHeld: Integer read fTerminalRetainedBytes; property RetainedSendBytes: Integer read GetRetainedSendBytes;
RetainedSendBytes is the memory held by queued send buffers, each counted at its full length until completely sent: the figure MaxBufferedSendBytes limits. QueuedSendParts counts those buffers (limit cHttp3ClientMaxQueuedSendParts). A QUIC-backed producer uses RetainedSendBytes in its admission check (HTTP.txt section 23.3).
property QueuedSendParts: Integer read GetQueuedSendParts; property GoneAway: Boolean read fGoneAway;

Routines