-
Notifications
You must be signed in to change notification settings - Fork 31
feat: Add proxy support including HTTP_PROXY, HTTPS_PROXY detection #115
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
base: feat/hyper-as-feature
Are you sure you want to change the base?
Conversation
This commit introduces proxy handling functionality for the hyper transport, including automatic instrumentation through environment variables. If HTTPS_PROXY is defined, all HTTPS traffic will potentially be routed through this proxy. If HTTP_PROXY is ALSO specified, then HTTP traffic will be routed through it. However, if HTTP_PROXY is specified without HTTPS_PROXY, then all traffic (http and https) will be routed through the HTTP_PROXY.
|
Looks like CI has a rust edition problem. |
| /// For HTTPS support or timeout configuration, use [`HyperTransport::builder()`]. | ||
| pub fn new() -> Self { | ||
| pub fn new() -> Result<Self, std::io::Error> { | ||
| //let client = HyperTransportBuilder::default().build_http(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| //let client = HyperTransportBuilder::default().build_http(); |
| let byte_stream: ByteStream = Box::pin(body_to_stream(body)); | ||
| /// Check if the given host matches the no_proxy rules. If this function returns true, the | ||
| /// proxy should be bypassed. | ||
| fn matches(&self, host: &str) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about the matching logic here. If nothing else it wouldn't match other no proxy implementations.
I think others would be doing some parsing of the parts.
I think these would all be different from other implementations.
NO_PROXY=ample.com → matches "example.com"
NO_PROXY=10.0.0.0/8 → won't match "10.1.2.3"
NO_PROXY=localhost → won't match "localhost:8080"
Which would make be hesitant to use the NO_PROXY environment variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to have tests for this.
I want if we may want to considering looking at https://github.com/jdrouet/no-proxy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just using that crate directly makes a lot of sense, so I've pulled that in.
This commit introduces proxy handling functionality for the hyper
transport, including automatic instrumentation through environment
variables.
If HTTPS_PROXY is defined, all HTTPS traffic will potentially be routed
through this proxy.
If HTTP_PROXY is ALSO specified, then HTTP traffic will be routed
through it. However, if HTTP_PROXY is specified without HTTPS_PROXY,
then all traffic (http and https) will be routed through the HTTP_PROXY.