-
-
Notifications
You must be signed in to change notification settings - Fork 829
-
-
Notifications
You must be signed in to change notification settings - Fork 829
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 system proxy exclusions. #1536
Comments
A useful starting point is here... proxyOverride = proxyOverride.split(';')
# now check if we match one of the registry values.
for test in proxyOverride:
if test == '<local>':
if '.' not in rawHost:
return 1
test = test.replace(".", r"\.") # mask dots
test = test.replace("*", r".*") # change glob sequence
test = test.replace("?", r".") # change glob char
On my system this returns... >>> _get_proxy_settings()
{'exclude_simple': False, 'exceptions': ('*.local', '169.254/16',)} There's also an example documented in the { 'exclude_simple': bool, 'exceptions': ['foo.bar', '*.bar.com', '127.0.0.1', '10.1', '10.0/16']} So, |
Thanks! I think
Besides, for the field 'exceptions' , |
Sticking to environment only settings would be one option, yes, though I'm not convinced that'd be the best from a user-experiance point of view. |
Being able to pick up and use the system proxy settings — especially proxy auto config — would be a benefit in certain environments, even if it’s an option and not the default. I’m no longer in a situation like that, but Python PAC support on macOS could have made configuring some projects much easier. It might have been a reason to choose a library like HTTPX over another. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Still valid at the moment. Could do with a review and possibly extra docs. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Upping the durations on you, @stalebot. Shoo. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Nothing's changed in this topic i presume? |
Lines 195 to 215 in db9072f
On Windows: def getproxies():
return getproxies_environment() or getproxies_registry()
A possible solution for Windows is to rewrite |
We're currently leaning on
urllib.request.getproxies()
to determine the system proxy setup, and setup which mounts should be a proxy transport and which should be a regular transport.However, we're not using
urllib.request.proxy_bypass(host)
.This all works as expected when environment settings are being used.
HTTP_PROXY
,HTTPS_PROXY
, andALL_PROXY
. In that case we're readingNO_PROXY
, and ensuring anything hostname patterns there are mounted as a regular transport...httpx/httpx/_utils.py
Lines 304 to 320 in 68cf1ff
However, in the case when none of those environment variables are set
getproxies()
instead falls back to system proxy configuration. For windows this is registry based.ProxyEnable
andProxyOverride
. For Mac this is sysconf based.In those cases, we're correctly getting the configured proxies, but we aren't dealing with proxy exclusions.
We'd like to be able to setup these exclusions with our neat hostname pattern matched mounts system, which actually
means we can't just fallback to
urllib.request.proxy_bypass(host)
, because that needs to be called per-host.So, first steps...
ProxyOverride
field?from _scproxy import _get_proxy_settings()
?The text was updated successfully, but these errors were encountered: