Requests | HTTP/2 Server Push

Server Push is the ability of the server to send multiple responses for a single client request. That is, in addition to the response to the original request, the server can push additional resources to the client, without the client having to request each one explicitly.

 

 

Every time server sends to client a PushPromise message, OnHTTP2PushPromise event is called. When client receives a PushPromise, means that server will send in the next packets this resource, so client can accepts or not this.

 


TsgcHTTP2Client oClient = new TsgcHTTP2Client();
oClient->OnHTTP2PushPromise = OnHTTP2PushPromiseEvent;
oClient->Get("https://http2.golang.org/serverpush");
...
void OnHTTP2PushPromiseEvent(TObject *Sender; const TsgcHTTP2ConnectionClient *Connection; 
  const TsgcHTTP2_Frame_PushPromise *PushPromise; ref boolean Cancel)
{
  if (PushPromise->URL == "/serverpush/static/godocs.js")
  {
    Cancel = true;
  }
  else
  {
    Cancel = false;
  }
}