-
Notifications
You must be signed in to change notification settings - Fork 470
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
Connect through a proxy if environment variables are set. #369
Labels
Comments
I would like to work on this feature. |
@whizsid Great! Seems there is an example here: https://github.com/hyperium/hyper/blob/master/examples/http_proxy.rs |
@tomusdrw I took another approach. But I would like to accept your suggestions. #[cfg(feature = "http-tls")]
#[derive(Debug, Clone)]
enum Client {
Proxy(hyper::Client<hyper_proxy::ProxyConnector<hyper_tls::HttpsConnector<hyper::client::HttpConnector>>>),
NoProxy(hyper::Client<hyper_tls::HttpsConnector<hyper::client::HttpConnector>>),
}
#[cfg(not(feature = "http-tls"))]
#[derive(Debug, Clone)]
enum Client {
Proxy(hyper::Client<hyper_proxy::ProxyConnector<hyper::clinet::HttpConnector>>),
NoProxy(hyper::Client<hyper::client::HttpConnector>),
}
impl Client {
pub fn request(&self, req: hyper::Request<hyper::Body>) -> hyper::client::ResponseFuture {
match self {
Client::Proxy(client) => client.request(req),
Client::NoProxy(client) => client.request(req),
}
}
} May I continue with this approach? or with the above example? |
@whizsid Yup, looks good! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be nice, if a connection was established through proxies as specified in the env vars: http_proxy, https_proxy, HTTP_PROXY or HTTPS_PROXY
It looks like hyper has support for it, but requires the client to read the env vars.
The text was updated successfully, but these errors were encountered: