TsgcHTTP3Client › Events › OnPushPromise
Fires when the server promises to push a resource, before the pushed response arrives.
TsgcHTTP3PushPromiseEvent = procedure(Sender: TObject; aPushId: Int64;
const aHeaders: TStringList) of object;
property OnPushPromise: TsgcHTTP3PushPromiseEvent read FOnPushPromise
write FOnPushPromise;
| Name | Type | Description |
|---|---|---|
Sender | TObject | The TsgcHTTP3Client instance that raised the event. |
aPushId | Int64 | Identifier of the promised push. Pass it to CancelPush to refuse the push. |
aHeaders | const TStringList | Headers of the request the server is answering on your behalf, including the :method and :path pseudo-headers. The list is only valid inside the handler. |
A PUSH_PROMISE frame (RFC 9114 Section 7.2.5) tells the client that the server intends to send a resource it was not asked for, because it expects the client will need it. The promise carries the request headers the push will answer, which lets the client decide whether it wants the resource before the bytes are spent.
This event is that decision point. If the resource is already cached or simply unwanted, call CancelPush with aPushId from the handler. Otherwise do nothing and the pushed response is delivered later on OnPush, carrying the same push ID.
Server push is disabled until the client raises the limit with SetMaxPushId, so this event never fires unless that call was made.
procedure TfrmMain.OnPushPromiseEvent(Sender: TObject; aPushId: Int64;
const aHeaders: TStringList);
begin
if aHeaders.Values[':path'] = '/already-cached.css' then
oClient.CancelPush(aPushId);
end;