TsgcHTTP2Client | HTTP/2 Partial Responses

일반적으로 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;