HTTP client: CONNECT tunnel support#1466
Open
WaberZhuang wants to merge 1 commit into
Open
Conversation
WaberZhuang
marked this pull request as draft
June 17, 2026 04:13
WaberZhuang
marked this pull request as ready for review
June 29, 2026 12:56
WaberZhuang
force-pushed
the
main
branch
4 times, most recently
from
July 3, 2026 07:36
474c2ba to
3173d28
Compare
WaberZhuang
force-pushed
the
main
branch
8 times, most recently
from
July 16, 2026 08:53
4dbc061 to
1496488
Compare
Signed-off-by: zhuangbowei.zbw <zhuangbowei.zbw@alibaba-inc.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
CONNECT tunnel for HTTPS proxy (new)
HTTPS targets through an HTTP/HTTPS proxy are now handled via CONNECT tunnels (RFC 7231 §4.3.6). Previously only HTTP/1.1 forward proxy was supported; HTTPS proxy connections would fail or produce incorrect requests.
The tunnel logic is implemented as private methods of
PooledDialer(make_tunnel_stream,do_connect_handshake), reusing the sameISocketPoolinstance for connection grouping — no separate pool class introduced.proxy_header(new interface)A new
CommonHeaders<> proxy_headerfield is introduced onOperation, with a companionCommonHeaders<>* proxy_headers()accessor onClient, dedicated to proxy-handshake headers (e.g.Proxy-Authorization). This separates proxy headers fromreq.headers(target-server headers).Priority chain in
call():proxy_headeris merged intoreq.headersbefore sending. Existing code that setsProxy-Authorizationinreq.headersstill works —mergewithallow_dup=0preserves the destination's existing value.proxy_headeris consumed exclusively by the CONNECT handshake;req.headersis sent to the target server after the tunnel is established.set_proxy()behavior changeset_proxy(url): now also resetsop->proxy_header— old proxy's auth headers are no longer valid for the new proxy.set_proxy(url): now also resetsclient->proxy_headers().Note: the old
m_proxy_authfield is removed. Auth is now derived from the proxy URL atcall()time and lives inproxy_header.Key-based connection pooling (internal)
All connection types — direct TCP/TLS, HTTP proxy, and CONNECT tunnel — share a single
ISocketPool(new_tcp_socket_pool) viaconnect(key, connector). Connection grouping is purely by key:<host>:<port>:<0|1>(0=TCP, 1=TLS)<proxy_host>:<proxy_port>:<s|p>:<target_host>:<target_port>[:<auth>]The
connectorlambda (passed asTempDelegate, zerostd::functionoverhead) is the factory that establishes new connections on pool miss. Different auth credentials or target endpoints produce different keys, preventing cross-contamination.Verification