-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(client): fix Host header when using a Proxy #775
Conversation
@shaleh do you mind testing that this works with your proxy? |
This works for HTTP like www.example.com but fails for HTTPS like https://google.com. I get a response back from the proxy server telling me the request is invalid.
|
To support |
This is the sequence that works via telnet/nc
Note the use of a port number instead of "http://". When I tried to use http://www.example.com I would get back an invalid request response. Since you have the |
Exchanging the 80 for 443 and starting the SSL/TLS stack should be enough to get HTTPS working. |
Yea, the issue is that by the time the code in I'm now thinking of composing struct Tunnel<C> {
connector: C,
proxy: (String, String, u16),
}
type HttpToHttpsProxy = HttpsConnector<Openssl, Tunnel<HttpConnector>>;
let http_to_https_proxy = HttpsConnector::new(
Openssl::default(),
Tunnel::new(
HttpConnector, "http", "my-proxy", 8080
)
); Steps that would occur:
|
Are you thinking for making a |
Or, HttpsConnector (and HttpConnector) could have a |
It does seem that this is entirely implementable with the tools hyper provides, but I suppose this can be provided to ease usage of proxies for the easy cases. Those cases seem to be:
As before, any attempt to connect to the proxy or the target over https without the Next, to set it up on the Client, it could look like this: // if target-uri is https, tunnels over http to proxy, otherwise does absolute-uri as in current PR
// if ssl feature is disabled, requests to https would return `Err(unknown scheme)`
let client = Client::with_proxy("http", "my-proxy", 8080); |
And thanks to a mistake in designing the Though just think of that sounds horrible. Double encryption yum. |
Ah, seems that is a job for NPN... |
NPN? |
Next Protocol Negotiation, a recent addition to TLS. It allows converting a TLS connection into some other connection (it was originally created for SPDY/HTTP2 so clients can upgrade TLS to h2). But that's a lot of work, and from my googling, the majority of people use HTTP proxies, not HTTPS, so I'm going to settle by only providing to HTTP out of the box (I want to get back to the async work). Client::with_http_proxy("my-proxy", 8080) It will always try the |
But it still proxies for connections to HTTPS sites, right? Lots and lots of websites are HTTPS these days. |
Yes, it will tunnel to the HTTP proxy, and negotiate TLS after the proxy has tunneled tcp. |
Cool. Let me know when you need me to play QA again :-) |
7d38cbc
to
4e59307
Compare
I'm not super pleased with the code, but it seems to work. Tests pass, and I edited the |
4e59307
to
f36c6b2
Compare
@shaleh does it work with your corporate proxy? With this PR, you can do |
I will check it tomorrow. I had planned today but was busy. |
I get a failure:
wget, curl, etc. all work. I have not had the time to debug this. Sorry. |
@shaleh The value provided does not include the scheme, right? The code in the example doesn't do as much parsing as it could have the |
Bingo. I have had problems with other software failing if the variable left off the |
Closes #774