TsgcHTTP2Client › Events › OnHTTP2ResponseFragment
Fires for each streamed response fragment when FragmentedData delivers data as it arrives.
property OnHTTP2ResponseFragment: TsgcHTTP2ClientResponseFragmentEvent;
// TsgcHTTP2ClientResponseFragmentEvent = procedure(Sender: TObject; const Connection: TsgcHTTP2ConnectionClient; const Request: TsgcHTTP2RequestProperty; const Fragment: TsgcHTTP2ResponseFragmentProperty) of object
—
OnHTTP2ResponseFragment is raised every time a partial response packet is received, so the stream can be processed as soon as the bytes arrive instead of waiting for the whole payload. It is typically used with long lived or chunked HTTP/2 streams (for example event streams or clockstream style endpoints) and is enabled by setting FragmentedData to h2fdAll (also raises OnHTTP2Response when the last packet arrives) or h2fdOnlyFragmented (only this event is dispatched). The Fragment parameter exposes the partial payload through Data, DataString and DataUTF8; the Request parameter identifies the originating 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;