grpc/client: HTTP CONNECT proxy support in transport#2698
Merged
Conversation
This reverts commit 0428123.
arjan-bal
marked this pull request as draft
June 22, 2026 08:08
arjan-bal
added a commit
that referenced
this pull request
Jul 3, 2026
…ration (#2679) This PR implements a resolver wrapper that determines proxy routing by checking the `HTTPS_PROXY` and `NO_PROXY` environment variables. By default, `hyper-util` matches cURL's behavior by falling back to `ALL_PROXY` when `HTTPS_PROXY` is unset. However, because Go's [`FromEnvironment`](https://pkg.go.dev/golang.org/x/net/http/httpproxy#FromEnvironment) and gRPC C++ ignore `ALL_PROXY`, gRPC Rust manually configures the `Matcher` to bypass it, ensuring cross-language consistency. **Resolution Flow** When `HttpsProxyResolver::Builder` builds a resolver for a target URI, it uses `hyper_util::client::proxy::Matcher` to evaluate the environment variables: 1. **Direct Connection:** If no proxy is required, it delegates resolution entirely to the wrapped child builder, bypassing the proxy resolver. 2. **Proxied Connection:** If a proxy is required, it creates an `HttpsProxyResolver`, which uses the child DNS resolver to resolve the *proxy server's* hostname instead of the target. 3. **Attribute Injection:** The `HttpsProxyResolver` intercepts resolution updates from the child resolver. It attaches the necessary proxy configuration (the original target authority and basic auth credentials) as attributes to each resolved proxy address. In follow-up PRs, the subchannel will read these address attributes to wrap the channel credentials and carry out the HTTP `CONNECT` handshake prior to the standard credential handshake. Internal design doc: [go/grpc-rust-http-connect](http://go/grpc-rust-http-connect) Transport changes: #2698
arjan-bal
force-pushed
the
http-proxy-transport
branch
from
July 3, 2026 09:50
1b5c061 to
bbde691
Compare
arjan-bal
marked this pull request as ready for review
July 3, 2026 09:58
dfawley
reviewed
Jul 7, 2026
dfawley
left a comment
Member
There was a problem hiding this comment.
I still need to look at the tests, but here's a first round of comments (all pretty minor I think).
arjan-bal
force-pushed
the
http-proxy-transport
branch
from
July 14, 2026 09:31
e8496e4 to
a0c54c7
Compare
dfawley
approved these changes
Jul 23, 2026
Comment on lines
+154
to
+169
| let certs_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) | ||
| .parent() | ||
| .unwrap() | ||
| .join("examples/data/tls"); | ||
|
|
||
| let server_cert = fs::read(certs_path.join("server.pem")).expect("failed to read server.pem"); | ||
| let server_key = fs::read(certs_path.join("server.key")).expect("failed to read server.key"); | ||
| let ca_cert = fs::read(certs_path.join("ca.pem")).expect("failed to read ca.pem"); | ||
|
|
||
| let identity = Identity::from_pem(server_cert, server_key); | ||
| let identity_provider = StaticProvider::new(vec![identity]); | ||
| let server_tls_config = ServerTlsConfig::new(identity_provider); | ||
| let server_creds = RustlsServerCredendials::new(server_tls_config).unwrap(); | ||
|
|
||
| let server_listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); | ||
| let server_addr = server_listener.local_addr().unwrap(); |
Member
There was a problem hiding this comment.
Maybe we can make some helpers to avoid some of the duplication here? Even if it's broken up into a few smaller and reusable parts, like one function that creates the credentials, that could be helpful.
Contributor
Author
There was a problem hiding this comment.
Created helper functions to construct client/server credentials, perform the CONNECT handshake, and initialize the server.
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.
This PR introduces an
HttpConnectHandshakerthat wraps theChannelCredentialsto complete the HTTP CONNECT handshake based on theAddressattributes introduced in #2679. This allows the subchannel to configure proxying transparently without requiring changes to the Transport API.