TsgcHTTP3Client › Events › OnPush
Fires when a complete pushed response has been received from the server.
TsgcHTTP3PushEvent = procedure(Sender: TObject; aPushId: Int64;
const aResponse: TsgcHTTP3Response) of object;
property OnPush: TsgcHTTP3PushEvent read FOnPush write FOnPush;
| Name | Type | Description |
|---|---|---|
Sender | TObject | The TsgcHTTP3Client instance that raised the event. |
aPushId | Int64 | Identifier of the push, matching the one reported earlier on OnPushPromise. |
aResponse | const TsgcHTTP3Response | The pushed response, with its status, headers and body. Call GetDataAsString to decode the body as text. Valid only inside the handler. |
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.
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;