TsgcHTTP3Client › Methods › Get

Get Method

Sends a synchronous HTTP/3 GET request, returning the response body as a string or writing it to a stream.

Syntax

Get(const aURL: string): string string overload

function Get(const aURL: string): string; overload;
NameTypeDescription
aURLconst stringAbsolute URL of the target resource.

Response body received from the server, decoded as a string. (string)

Get(const aURL: string; const aResponseContent: TStream) stream overload

procedure Get(const aURL: string;

  const aResponseContent: TStream); overload;
NameTypeDescription
aURLconst stringAbsolute URL of the target resource.
aResponseContentTStreamStream that receives the response body.

None. The response body is written to aResponseContent.

Remarks

The call blocks the calling thread until the complete response has been received. When the client is not connected yet, the URL is used to open the QUIC connection first. For a non-blocking request use GetAsync, which delivers the reply on OnResponse.

GET retrieves a representation of the target resource and carries no request body. Use the string overload when the payload is textual (HTML, JSON, XML) and fits comfortably in memory, and the stream overload to download binary or large content straight into a TFileStream or TMemoryStream without building an intermediate string.

The amount of body data accepted can be capped with MaxResponseSize. This client does not follow redirects automatically, so a 3xx status must be handled by the caller.

Example



vJSON := oClient.Get('https://api.example.com/v1/users');



// stream overload

oStream := TFileStream.Create('file.bin', fmCreate);

try

  oClient.Get('https://api.example.com/v1/file.bin', oStream);

finally

  oStream.Free;

end;

Back to Methods