-
Notifications
You must be signed in to change notification settings - Fork 278
Handle proxy variables #2789
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
Handle proxy variables #2789
Conversation
2ccefa3
to
f396735
Compare
3656375
to
be9c0b3
Compare
from __future__ import annotations | ||
|
||
from typing import Any | ||
from urllib.request import getproxies |
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.
we could implement this method ourselves as well but I tried to keep this minimal
urllib3 does not handle this but we do want to support proxy users. The environment variable handling is slightly simplified from the requests implementation. Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
This does not actually test using tuf through proxies: it only tests that ProxyEnvironment creates the ProxyManagers that we expect to be created based on the proxy environment variables. Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
Add support for leading dots in no_proxy and "*" as a no_proxy value. Both are supported in requests and based on https://about.gitlab.com/blog/2021/01/27/we-need-to-talk-no-proxy/ both are somewhat common. Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
e2b2aec
to
98fcd71
Compare
rebased on develop after #2773 merged |
@jku, this is an impressive work! Thank you for dedicating time on it. |
I think the |
This PR handles proxy variables (notably
http_proxy
,https_proxy
,no_proxy
,all_proxy
) when using Urllib3Fetcher:ProxyEnvironment
is used like urllib3PoolManager
: it has the samerequest()
method (we could easily implement the whole RequestMethods mixin but since we only use the one method, that didn't seem useful)ProxyEnvironment
keeps track of typically 1-3 PoolManagers [non-proxied, http-proxied, https-proxied] and chooses between those based on the requested url and the environment variablesI did not want to implement this as I think this component should be in urllib3 but it's not a lot of code (maybe 50 lines of actual code) so I can live with it. As far as I know this puts python-tuf back to feature parity with v5.1: this was the only feature that I know of that we lost with the move from
requests
tourllib3
only.Fixes #2787