TsgcHTTP3Client › Events › OnPush

OnPush Event

Fires when a complete pushed response has been received from the server.

Syntax

TsgcHTTP3PushEvent = procedure(Sender: TObject; aPushId: Int64;

  const aResponse: TsgcHTTP3Response) of object;



property OnPush: TsgcHTTP3PushEvent read FOnPush write FOnPush;

Parameters

NameTypeDescription
SenderTObjectThe TsgcHTTP3Client instance that raised the event.
aPushIdInt64Identifier of the push, matching the one reported earlier on OnPushPromise.
aResponseconst TsgcHTTP3ResponseThe pushed response, with its status, headers and body. Call GetDataAsString to decode the body as text. Valid only inside the handler.

Remarks

OnPush delivers a resource the server sent without being asked, once its push stream is complete. Each push arrives on its own unidirectional stream that carries the push ID followed by the response headers and body (RFC 9114 Section 4.6), and the client assembles them into a normal response object.

The sequence for any push is OnPushPromise first, carrying the request headers the push will answer, and then this event with the response itself. Match the two by aPushId. A push refused with CancelPush never reaches this event.

Server push is disabled by default. The event only fires after the client has raised the limit with SetMaxPushId, and only for push IDs within that limit.

The typical use is to place the pushed resource in an application cache so that a later request for the same path is served locally. The response object belongs to the client, so copy anything you need to keep.

This member is currently available in the Delphi/C++Builder implementation only.

Example



oClient.OnPushPromise := OnPushPromiseEvent;

oClient.OnPush := OnPushEvent;

oClient.SetMaxPushId(9);



procedure TfrmMain.OnPushEvent(Sender: TObject; aPushId: Int64;

  const aResponse: TsgcHTTP3Response);

begin

  Log(Format('push %d: HTTP %d, %d bytes',

    [aPushId, aResponse.StatusCode, Length(aResponse.Data)]));

end;

Back to Events