TsgcHTTP2ClientOlaylar › OnHTTP2PushPromise

OnHTTP2PushPromise Olay

Sunucu bir kaynak gönderdiğinde tetiklenir, böylece istemci bunu kabul edebilir veya iptal edebilir.

Sözdizimi

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

Varsayılan Değer

Remarks

OnHTTP2PushPromise, sunucu bir PUSH_PROMISE çerçevesi gönderdiğinde tetiklenir; kendi inisiyatifiyle ek bir kaynağı (örneğin istemcinin az önce istediği bir sayfayla ilişkili bir görüntü veya betik) göndermek üzere olduğunu duyurur. PushPromise parametresi, vaat edilen kaynağı (method, URL, headers) açıklar, böylece uygulama ilginç olup olmadığına karar verebilir. Gönderilen stream'i reddetmek için Cancel'ı True olarak ayarlayın (istemci bir RST_STREAM gönderir) veya kabul etmek için False bırakın; bu durumda veri daha sonra OnHTTP2Response / OnHTTP2ResponseFragment aracılığıyla teslim edilir. Server push yalnızca Settings.EnablePush True olduğunda alınır.

Örnek


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;

Olaylara Dön