-
Notifications
You must be signed in to change notification settings - Fork 179
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
Respect NO_PROXY
environment variable.
#668
Comments
Zicklag ***@***.***> wrote:
`NO_PROXY` environment variables. Also, it's not possible to
efficiently implement from outside of `ureq`, because you would have to
create a new `Agent` for each request to a different domain, instead of
being able to share the same agent state among all domains.
Also redirects that had different proxy needs wouldn't work.
|
I know very little about proxies. PR welcome.
Agent is reusable for multiple requests.
Not sure I follow. Do you mean there should be different proxy settings per request host? |
Martin Algesten ***@***.***> wrote:
> Also redirects that had different proxy needs wouldn't work.
Not sure I follow. Do you mean there should be different proxy settings per request host?
The point of NO_PROXY is that it does not use the proxy for certain hosts.
So, in effect, yes, there are different proxy settings (namely: none) for
some hosts.
|
ureq 3.x needs support for this. We should do all the options curl does: https://github.com/curl/curl/blob/master/docs/libcurl/opts/CURLOPT_NOPROXY.md |
In general, proxy lookup should use the interface If the list is empty or contains This allows to implement generic per-URL proxy lookup with complex exclusion rules, PAC URL lookup (see seanmonstar/reqwest#1764 for some diagrams showing real-world proxy lookup with PAC URLs), multiple proxy types (e.g. return both an HTTP and a SOCKS proxy URL, and ureq automatically picks the one it suppots), dynamic per-network proxy lookup (e.g. use no proxy in the public WiFi connection on the train to work, and then automatically use the corporate proxy once at office, without restarting the running application) etc. On top of this interface it's trivial to implement |
Thanks! Very useful info! Is there a crate that abstracts parts of this? I don't want ureq to directly call glibc or winapi. |
Oh I'm sorry, that's not what I meant. I don't think ureq should call system-specific APIs to call proxy lookups, nor link to a crate which does that. That's a lot of work (e.g. the Windows API around this is exceptionally ugly), and very brittle, as some of these APIs are not always available (e.g. the GIO API is usually only available in a desktop environment, but not e.g. in a container or a headless server). ureq should just provide the appropriate interface to hook into, i.e. the function outlined in my previous comment. Then users of ureq can implement whatever proxy support they require: In a server application I'd perhaps just not use proxies at all, in a command line tool I could use env-proxy for curl-style environment variables, in e.g. a Linux desktop application I could use the GIO proxy resolver, or the equivalent API in Qt, or directly talk to the corresponding portal API, and in Windows I could get my hands dirty with the windows API. But I think ureq should leave that users, and not implement any default. With the above API you wouldn't even have to implement environment variables in ureq, and instead just refer to the env-proxy crate for TL;DR: |
Ah. Got ya. Should be fairly In ureq 3x we might not need to do anything. The |
I think I'd appreciate a convenience API on the |
I guess I'm a bit confused on how common these proxy configurations are. On the one hand you say we don't want to build in support for calling these brittle syscalls (for which I'm grateful), on the other we want something simpler than building our own One intention with making the |
I can't comment on transports, as I haven't tried building my own transport yet. I just noticed that the documentation doesn't mention transports prominently, and as said even states that they aren't for regular use, so I didn't associate them with proxy support which is pretty regular use if an HTTP library I'd say. So perhaps it's just a matter of documenting transports more prominently? |
This is a fairly trivial feature to implement in ureq 3.x. I mark it as help wanted. |
With the
try_proxy_from_env(true)
option,ureq
correctly reads theHTTP[S]_PROXY
environment variables, but it doesn't honor theNO_PROXY
environment variables. Also, it's not possible to efficiently implement from outside ofureq
, because you would have to create a newAgent
for each request to a different domain, instead of being able to share the same agent state among all domains.The text was updated successfully, but these errors were encountered: