Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Http.Http2Conn

******************************************************************************

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

Classes, interfaces and records

classtHttp2Stream

constructor Create(aID: Cardinal; aSendWindow, aRecvWindow: Integer); destructor Destroy; override;

A stream on tHttp2Conn's list of streams reset under a peer that may still be sending on them (fResetIDs): the streams listed just before and just after it, 0 at either end - 0 is never a peer's stream.

Older: Cardinal; Newer: Cardinal;

classtHttp2Conn

constructor Create(const aRemoteAddress: string); destructor Destroy; override; procedure Opened;
emit server SETTINGS
procedure RefuseConnection(aErrorCode: Cardinal);
ENDS THE CONNECTION at once with GOAWAY(aErrorCode), for a requirement the engine cannot see itself - the TLS version, which RFC 9113 s9.2 sets: "Implementations of HTTP/2 MUST use TLS version 1.2 [TLS12] or higher for HTTP/2 over TLS." The owner calls it after Opened, so the peer gets the server preface first; nothing is dispatched afterwards, and OnClose fires.
procedure Receive(aData: Pointer; aLen: Integer);
drive the frame loop
procedure ReceiveEarly(aData: Pointer; aLen: Integer);
Feed 0-RTT plaintext. Identical to Receive except that every stream it touches is marked EarlyData, so the request objects come out flagged and the RFC 8470 policy gate above the router can act on them.
procedure ResumeOutput;
THE OWNER HAS ROOM AGAIN - call it when the transport reports that it has sent something (iAppSessionDrain.Drained). Full description »
procedure Closed; procedure WorkQueued;
Does the work that is due: expires the HeaderTimeoutMSec and RequestTimeoutMSec deadlines that have passed, applies what streaming request handlers have posted (body credit, their response, a cancel) and sends the resulting output. Call it on the connection's own thread, never alongside Receive: when the time passed to OnWorkDeadline has come, and after a Wake. Receive also runs it first.
property Router: iHttpRouter read fRouter write fRouter; property SessionProvider: iHttpSessionProvider read fSessionProvider write fSessionProvider; property Wake: iHttpServerWake read fWake write fWake;
The owner's side of WorkQueued; without both, streaming routes are answered 503. Wake may be called on any thread, a handler's included, and must only ask the owner to call WorkQueued later; if it raises, that request fails. OnWorkDeadline, called on the connection's own thread, receives the earliest pending deadline as a stTlsUtils.GetTickCount64 value, or 0 when none is pending.
property OnWorkDeadline: tHttp2DeadlineEvent read fOnWorkDeadline write fOnWorkDeadline; property HeaderTimeoutMSec: Integer read fHeaderTimeoutMSec write fHeaderTimeoutMSec;
Absolute limits, in milliseconds, on how long a peer may take; 0 (or less) turns that limit off. HeaderTimeoutMSec bounds the client preface and first SETTINGS, every incomplete frame and each HEADERS/CONTINUATION block; on expiry the connection ends with GOAWAY(ENHANCE_YOUR_CALM). Full description »
property RequestTimeoutMSec: Integer read fRequestTimeoutMSec write fRequestTimeoutMSec; property OnResolvedDispatch: tHttp2ResolvedDispatchEvent read fOnResolvedDispatch write fOnResolvedDispatch; property OnPrepareStreamingResponse: tHttp2PrepareStreamingResponseEvent read fOnPrepareStreamingResponse write fOnPrepareStreamingResponse; property Session : iHttpSession read fSession write fSession;
Set once, before Opened. Both are simply copied onto each request built on this connection; nil is allowed and leaves the corresponding request property nil.
property ConnectionInfo: iHttpConnectionInfo read fConnInfo write fConnInfo; property OnOutput : tHttp2OutputEvent read fOnOutput write fOnOutput; property OnDispatch: tHttp2DispatchEvent read fOnDispatch write fOnDispatch; property OnClose : TNotifyEvent read fOnClose write fOnClose; property OnChargeBody : tHttp2ChargeEvent read fOnChargeBody write fOnChargeBody; property OnReleaseBody: tHttp2ReleaseEvent read fOnReleaseBody write fOnReleaseBody; property OnOutputRoom: tHttp2RoomEvent read fOnOutputRoom write fOnOutputRoom;
OUTPUT PACING. How many octets the owner can take through OnOutput now. Response DATA is only produced while the answer is positive, and what stalled resumes on ResumeOutput. Full description »
property OnChargeResponse : tHttp2ResponseBytesEvent read fOnChargeResponse write fOnChargeResponse;
The server-wide response budget: memory-held response octets taken on and let go, and the question asked before a new stream is opened. See MaxConnResponseBytes for the per-connection half. All three unassigned means no server-wide budget.
property OnReleaseResponse: tHttp2ResponseBytesEvent read fOnReleaseResponse write fOnReleaseResponse; property OnResponseBudgetFull: tHttp2BudgetFullEvent read fOnResponseBudgetFull write fOnResponseBudgetFull; property OnBodyRefused: tHttpBodyRefusedEvent read fOnBodyRefused write fOnBodyRefused;
EVERY REQUEST BODY A BOUND REFUSED, once, with the refusal already on its way to the peer: a content-length over MaxBodyBytes or MaxConnBodyBytes, answered 413 and then RST_STREAM(NO_ERROR), and a body that reaches one of them, or the owner's budget, as DATA, reset with ENHANCE_YOUR_CALM. Full description »
property BodyBytes: Int64 read fBodyBytes;
Assembled request-body octets currently held across all live streams.
property ResponseBytes: Int64 read fRespBytes;
Response octets held in memory across all live streams.
property OutgoingTrailerBytes: Int64 read fOutgoingTrailerBytes;
Response trailer sections held for streams that have not sent them yet, counted as names and values plus 32 bytes per field (OutgoingTrailerBytes), and the size of the encoded trailer block being written out now (OutgoingTrailerWireBytes, 0 when none). Neither counts in ResponseBytes.
property OutgoingTrailerWireBytes: Int64 read fOutgoingTrailerWireBytes; property MaxConcurrentStreams: Integer read fMaxConcurrentStreams write fMaxConcurrentStreams;
Set them BEFORE Opened: MaxConcurrentStreams and MaxHeaderListBytes are announced to the peer in the initial SETTINGS, so changing them afterwards would leave what we advertised and what we enforce disagreeing. Full description »
property MaxBodyBytes : Integer read fMaxBodyBytes write fMaxBodyBytes; property MaxConnBodyBytes : Integer read fMaxConnBodyBytes write fMaxConnBodyBytes; property MaxConnResponseBytes: Integer read fMaxConnResponseBytes write fMaxConnResponseBytes;
Memory-held response octets on this connection above which NEW streams are refused with REFUSED_STREAM - see cMaxConnResponseBytes. 0 = no per-connection limit.
property MaxHeaderBlockBytes: Integer read fMaxHeaderBlockBytes write fMaxHeaderBlockBytes; property MaxContinuationFrames : Integer read fMaxContinuationFrames write fMaxContinuationFrames; property MaxHeaderListBytes : Integer read fMaxHeaderListBytes write SetMaxHeaderListBytes;
Also pushed into the HPACK decoder, which is what actually enforces it.
property MaxStreamsPerConnection : Integer read fMaxStreamsPerConnection write fMaxStreamsPerConnection; property MaxUnproductiveFrames: Integer read fMaxUnproductive write SetMaxUnproductiveFrames;
Setting this refills the budget, so configure it before the peer arrives.
property StreamsOpened: Int64 read fStreamsOpened;
Observability: how many streams this connection has opened in total, and how much of the unproductive-frame budget is left.
property UnproductiveTokens: Integer read fUnproductive;

Types (enumerations, sets, aliases)

enumtHttp2StreamState

  tHttp2StreamState = (h2ssIdle, h2ssOpen, h2ssHalfClosedRemote, h2ssClosed);

proctHttp2OutputEvent

  tHttp2OutputEvent   = procedure (aData: Pointer; aLen: Integer) of object;

proctHttp2DispatchEvent

  tHttp2DispatchEvent = procedure (const aRequest: iHttpRequest;
                                   const aResponse: iHttpResponse) of object;

proctHttp2PrepareStreamingResponseEvent

  tHttp2PrepareStreamingResponseEvent = procedure(aSecure: Boolean;
    const aScheme, aAuthority: string; const aResponse: iHttpResponse) of object;

proctHttp2ResolvedDispatchEvent

Body-budget hooks. The engine is transport-free and owns no policy, so it asks whoever wired it up whether it may buffer more, and tells the same owner when it lets go. Unassigned means unlimited, which is what a standalone test harness wants. False from a charge is "not now" - the caller resets the stream, it does not kill the connection.

  tHttp2ResolvedDispatchEvent = procedure(const aRequest: iHttpRequest;
    const aResponse: iHttpResponse; const aHandler: iHttpRequestHandler) of object;

proctHttp2DeadlineEvent

  tHttp2DeadlineEvent = procedure(aDeadline: UInt64) of object;

proctHttp2ChargeEvent

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

proctHttp2ReleaseEvent

  tHttp2ReleaseEvent  = procedure (aBytes: Integer) of object;

proctHttp2RoomEvent

Output pacing: how many octets the owner can take through OnOutput right now. Unassigned means unlimited, which is what a standalone harness wants and what the engine did before it asked.

  tHttp2RoomEvent     = function: Integer of object;

proctHttp2ResponseBytesEvent

Response-budget hooks: memory-held response octets taken on and let go, and whether the owner's server-wide budget has room for another stream. Charging cannot be refused - by then the response exists - so it is the question at stream OPEN that does the bounding.

  tHttp2ResponseBytesEvent = procedure (aBytes: Int64) of object;

proctHttp2BudgetFullEvent

  tHttp2BudgetFullEvent    = function: Boolean of object;