TsgcHTTP3Client › Methods › Get
Sends a synchronous HTTP/3 GET request, returning the response body as a string or writing it to a stream.
function Get(const aURL: string): string; overload;
| Name | Type | Description |
|---|---|---|
aURL | const string | Absolute URL of the target resource. |
Response body received from the server, decoded as a string. (string)
procedure Get(const aURL: string;
const aResponseContent: TStream); overload;
| Name | Type | Description |
|---|---|---|
aURL | const string | Absolute URL of the target resource. |
aResponseContent | TStream | Stream that receives the response body. |
None. The response body is written to aResponseContent.
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.
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;