通常当您发送 HTTP 请求时,服务器会以所请求的文件进行响应;但有时服务器不是发送单个响应,而是像流一样发送多个响应,此时您可以使用 OnHTTP2ResponseFragment 事件捕获这些响应并向用户展示。
示例:向 https://http2.golang.org/clockstream 发送请求,服务器将每秒发送一次流式响应。
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;