TsgcHTTP3Client › Methods › Connect
Opens the QUIC connection to a host, or sends an HTTP/3 CONNECT request to establish a tunnel.
procedure Connect(const aHost: string; aPort: Integer = 443); overload;
| Name | Type | Description |
|---|---|---|
aHost | const string | IP address or DNS name of the HTTP/3 server. An IPv6 literal is accepted, an address that contains a colon is read as IPv6. When the host travels inside an absolute URL, the IPv6 literal must be bracketed, for example https://[::1]:443/. |
aPort | Integer | UDP port of the QUIC listener. Defaults to 443. |
None. On success Connected returns True and OnConnect fires.
function Connect(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)
Connect is overloaded and serves two distinct purposes. The host overload is a connection method: it opens the QUIC connection, performs the TLS 1.3 handshake, negotiates the h3 ALPN and opens the HTTP/3 control and QPACK streams. The URL overload is the HTTP CONNECT verb: it sends a request whose :method pseudo-header is CONNECT and returns the response body as a string.
The host overload does not normally need to be called explicitly, because every verb method opens the connection on demand from the URL. Call it when you want to control exactly when the handshake happens, or to fail fast before issuing requests. It also populates the read-only Host and Port properties.
To establish a tunnel or a WebTransport session, prefer ExtendedConnect, which sends the :protocol pseudo-header defined by RFC 9220 and keeps the request stream open. The plain CONNECT verb overload here simply issues the request and reads the response as an ordinary body.
Use Disconnect to close the connection and Connected to test its state.
// host overload: open the QUIC connection
oClient.Connect('www.example.com', 443);
if oClient.Connected then
vResponse := oClient.Get('https://www.example.com/');
// URL overload: the CONNECT verb
vResponse := oClient.Connect('https://www.example.com/tunnel');