Feature notes: HTTPS application layer notes (HTTP/1.1, h2, h3)
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);
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);
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);
MaxHeaderBlockBytes, MaxFieldSectionBytes, MaxBufferedSendBytes: Integer;
MaxActiveRequests, MaxRequests, MaxPeerUniStreams, MaxHeldBodyBytes: Integer;
MaxUnproductiveFrames: Integer;
QpackTableCapacity, QpackBlockedStreams, MaxQpackBlockedBytes: Integer;
MaxPushes, MaxActivePushes, MaxPushBufferedBytes, PushTimeoutMSec: Integer;
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;
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;
function StartRequest(const aMethod, aScheme, aAuthority, aPath: string; const aHeaders: tQpackFields; const aBody: TBytes; aEndStream: Boolean): UInt64; overload;
function RequestBodyOpen(aStreamID: UInt64): Boolean;
function RequestBodyPending(aStreamID: UInt64): Boolean;
function RequestBodyCapacity(aStreamID: UInt64): Integer;
function TrySendBody(aStreamID: UInt64; const aData: TBytes; aEndStream: Boolean): Boolean;
function TrySendTrailers(aStreamID: UInt64; const aTrailers: tHttpHeaders): Boolean;
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);
procedure CancelPush(aPushID: UInt64);
procedure BeginPushDrain(aFirstRejectedPushID: UInt64);
function NextPushDeadline(out aTickMS: UInt64): Boolean;
procedure Cancel(aStreamID: UInt64);
property Ready: Boolean read GetReady;
property Closed: Boolean read fClosed;
property SettingsReceived: Boolean read fSettingsReceived;
property QpackBlockedCount: Integer read fQpackBlockedCount;
property QpackBytesHeld: Integer read fQpackBlockedBytes;
property PeerSettings: tHttp3Settings read fPeerSettings;
property ActiveRequests: Integer read fActiveRequests;
property ActivePushes: Integer read fActivePushes;
property PushBytesHeld: Integer read fPushBytes;
property TrailerBytesHeld: Int64 read fHeldTrailerBytes;
property QueuedBytes: Integer read GetQueuedBytes;
property OutgoingTrailerBytesHeld: Int64 read fOutgoingTrailerBytes;
property TerminalSendBytesHeld: Integer read fTerminalRetainedBytes;
property RetainedSendBytes: Integer read GetRetainedSendBytes;
property QueuedSendParts: Integer read GetQueuedSendParts;
property GoneAway: Boolean read fGoneAway;