TsgcHTTP2ClientEvents › OnHTTP2PushPromise

OnHTTP2PushPromise Event

Fires when the server pushes a resource so the client can accept or cancel it.

Syntax

property OnHTTP2PushPromise: TsgcHTTP2ClientPushPromiseEvent;
// TsgcHTTP2ClientPushPromiseEvent = procedure(Sender: TObject; const Connection: TsgcHTTP2ConnectionClient; const PushPromise: TsgcHTTP2_Frame_PushPromise; var Cancel: Boolean) of object

Default Value

Remarks

OnHTTP2PushPromise is raised when the server sends a PUSH_PROMISE frame, announcing that it is about to push an additional resource on its own initiative (for example an image or script associated with a page the client has just requested). The PushPromise parameter describes the promised resource (method, URL, headers) so the application can decide whether it is interesting. Set Cancel to True to reject the pushed stream (the client will send an RST_STREAM) or leave it False to accept it, in which case the data will be delivered later through OnHTTP2Response / OnHTTP2ResponseFragment. Server push is only received when Settings.EnablePush is True.

Example


oClient := TsgcHTTP2Client.Create(nil);
oClient.OnHTTP2PushPromise := OnHTTP2PushPromiseEvent;
oClient.Get('https://http2.golang.org/serverpush');

procedure OnHTTP2PushPromiseEvent(Sender: TObject; const Connection: TsgcHTTP2ConnectionClient;
  const PushPromise: TsgcHTTP2_Frame_PushPromise; var Cancel: Boolean);
begin
  if PushPromise.URL = '/serverpush/static/godocs.js' then
    Cancel := True
  else
    Cancel := False;
end;

Back to Events