TsgcHTTP2Client | HTTP/2 部分レスポンス

通常 HTTP リクエストを送信するとサーバーはリクエストされたファイルの応答を送信しますが、単一の応答の代わりにサーバーがストリームのように複数の応答を送信する場合があります。その場合は OnHTTP2ResponseFragment イベントを使用してこれらの応答をキャプチャしてユーザーに表示できます。

 

使用例: https://http2.golang.org/clockstream にリクエストを送信すると、サーバーは 1 秒ごとにストリームレスポンスを送信します。

 


oClient := TsgcHTTP2Client.Create(nil);
oClient.OnHTTP2ResponseFragment := OnHTTP2ResponseFragmentEvent;
oClient.Get('https://http2.golang.org/clockstream');
...
procedure OnHTTP2ResponseFragmentEvent(Sender: TObject; const Connection: TsgcHTTP2ConnectionClient; 
  const Request: TsgcHTTP2RequestProperty; const Fragment: TsgcHTTP2ResponseFragmentProperty);
begin
  ShowMessage(Fragment.DataString);
end;