TsgcHTTP2Client › 事件 › OnHTTP2Response
当客户端收到来自服务器的完整响应(状态、头部和主体)时触发。
property OnHTTP2Response: TsgcHTTP2ClientResponseEvent;
// TsgcHTTP2ClientResponseEvent = procedure(Sender: TObject; const Connection: TsgcHTTP2ConnectionClient; const Request: TsgcHTTP2RequestProperty; const Response: TsgcHTTP2ResponseProperty) of object
—
OnHTTP2Response 在收到请求的完整 HTTP/2 响应后触发一次。Response 参数公开服务器返回的状态、头和正文:使用 Response.Headers 获取 HTTP/2 头列表,Response.Data 获取原始正文字节,Response.DataString 将正文作为字符串,Response.DataUTF8 将正文作为 UTF-8 字符串。Request 参数标识原始请求,以便在同一连接上关联多个未完成的流。当 FragmentedData 设置为 h2fdOnlyFragmented 时,不触发此事件,仅分发 OnHTTP2ResponseFragment。
procedure OnHTTP2ResponseEvent(Sender: TObject; const Connection: TsgcHTTP2ConnectionClient;
const Request: TsgcHTTP2RequestProperty; const Response: TsgcHTTP2ResponseProperty);
begin
ShowMessage(Response.Headers.Text + #13#10 + Response.DataString);
end;