TsgcHTTP2Client | HTTP/2 Download File

클라이언트가 서버에서 파일을 요청하면 OnHTTP2Response 이벤트를 사용하여 스트림 응답을 로드하십시오.

 

Large File Downloads

대용량 파일(수백 MB 이상)을 다운로드할 때, 기본 60초 시간 초과로 전송이 중단되지 않고 완료되도록 HTTP2Options.ReadTimeout0(시간 초과 없음)으로 설정하십시오:

 


oClient := TsgcHTTP2Client.Create(nil);
oClient.HTTP2Options.ReadTimeout := 0; // no timeout for large files
oClient.Get('https://server/largefile', oStream);

 


oClient := TsgcHTTP2Client.Create(nil);
oClient.OnHTTP2Response := OnHTTP2ResponseEvent;
oClient.Get('https://http2.golang.org/file/gopher.png');
...
procedure OnHTTP2ResponseEventEvent(Sender: TObject; const Connection: TsgcHTTP2ConnectionClient; 
  const Request: TsgcHTTP2RequestProperty; const Response: TsgcHTTP2ResponseProperty)
begin
  oStream := TFileStream.Create('file', fmOpenWrite or fmCreate);
  Try
    oStream.CopyFrom(Response.Data, Response.Data.Size);
  Finally
    oStream.Free;
  End;
end;