TsgcHTTP2Client › Methods › Connect
Establishes the HTTP/2 session and performs a blocking GET to the supplied URL.
function Connect(const aURL: string): string;
| Name | Type | Description |
|---|---|---|
aURL | const string | Absolute URL of the target resource. The scheme (https / http) selects between TLS-secured h2 and cleartext h2c. |
Response body received from the server decoded as a string. (string)
This overload opens the TCP/TLS transport, performs the ALPN/Upgrade negotiation, issues the initial GET request and returns once the entire response has been read. Use it when you need the full payload in memory as a string.
vResponse := oClient.Connect('https://api.example.com/status');
procedure Connect(Const aURL: string; const aResponseContent: TStream);
| Name | Type | Description |
|---|---|---|
aURL | const string | Absolute URL of the target resource used by the first HTTP/2 request. |
aResponseContent | const TStream | Caller-supplied stream that receives the response body; the position is advanced as bytes are written. Useful for large payloads or direct file output. |
This streaming overload behaves identically to the string-returning variant but writes the response directly to the supplied TStream, avoiding intermediate string allocation. Prefer it when the response does not need to be held in memory.
oStream := TFileStream.Create('out.bin', fmCreate);
try
oClient.Connect('https://api.example.com/download', oStream);
finally
oStream.Free;
end;