TsgcHTTP2Client › 이벤트 › OnHTTP2ResponseFragment
FragmentedData가 데이터를 도착하는 대로 전달할 때 각 스트리밍된 응답 프래그먼트에 대해 발생합니다.
property OnHTTP2ResponseFragment: TsgcHTTP2ClientResponseFragmentEvent;
// TsgcHTTP2ClientResponseFragmentEvent = procedure(Sender: TObject; const Connection: TsgcHTTP2ConnectionClient; const Request: TsgcHTTP2RequestProperty; const Fragment: TsgcHTTP2ResponseFragmentProperty) of object
—
OnHTTP2ResponseFragment는 부분 응답 패킷이 수신될 때마다 발생하므로, 전체 페이로드를 기다리는 대신 바이트가 도착하는 즉시 스트림을 처리할 수 있습니다. 일반적으로 장기 실행 또는 청크 단위 HTTP/2 스트림(예: 이벤트 스트림 또는 clockstream 스타일 엔드포인트)에 사용되며, FragmentedData를 h2fdAll(마지막 패킷이 도착할 때 OnHTTP2Response도 발생시킴) 또는 h2fdOnlyFragmented(이 이벤트만 디스패치됨)로 설정하여 활성화됩니다. Fragment 매개변수는 Data, DataString 및 DataUTF8을 통해 부분 페이로드를 노출합니다. Request 매개변수는 발생시킨 요청을 식별합니다.
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;