TsgcHTTP3Client › Methods › ExtendedConnect
Performs an Extended CONNECT handshake (RFC 9220) and keeps the request stream open as a tunnel.
function ExtendedConnect(const aURL, aProtocol: string): Boolean;
| Name | Type | Description |
|---|---|---|
aURL | const string | Absolute URL of the tunnel endpoint. Its host, port and path fill the :authority and :path pseudo-headers. |
aProtocol | const string | Value of the :protocol pseudo-header, for example websocket or webtransport. |
True when the server answered with a 2xx status and the tunnel is established, False when the server does not support Extended CONNECT or rejected the request. (Boolean)
ExtendedConnect implements the Extended CONNECT method defined in RFC 9220 for HTTP/3, the counterpart of RFC 8441 for HTTP/2. It opens or reuses the QUIC connection to the host in aURL and sends a request whose pseudo-headers are :method=CONNECT, :protocol=aProtocol, :scheme=https, plus :authority and :path taken from the URL.
The server must have advertised SETTINGS_ENABLE_CONNECT_PROTOCOL in its SETTINGS frame, otherwise the method returns False without sending anything. The client waits for the peer SETTINGS to arrive first, bounded by ConnectTimeout, and the advertised value can be inspected through PeerSettings.
The call then blocks until the response headers arrive, bounded by ReadTimeout. Unlike an ordinary request it does not wait for the stream to finish, because a tunnel keeps the request stream open (RFC 9114 Section 4.4). On a 2xx status the stream is retained as a tunnel and True is returned; any other status returns False.
Once the tunnel is up, write to it with TunnelSend and read from it by calling TunnelPump, which surfaces incoming bytes on OnTunnelData. To establish a WebTransport session use WebTransportConnect, which performs this handshake with the webtransport protocol and wraps the result in a session object.
This member is currently available in the Delphi/C++Builder implementation only.
if oClient.ExtendedConnect('https://www.example.com/tunnel', 'websocket') then
begin
oClient.OnTunnelData := OnTunnelDataEvent;
oClient.TunnelSend(TEncoding.UTF8.GetBytes('hello'));
oClient.TunnelPump(1000);
end;