Support no_proxy environment variable. #140 #145
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sorry if I've done any dumb stuff here. I tried to find a spec, and the nearest I could find was some ancient info from W3C. I've thus implemented a subset of what other popular libraries support.
no_proxy
contains a list of domain suffixes, separated by commas. The domain suffixes may optionally have leading periods; the commas may optionally have trailing spaces.For example, if
no_proxy=internal.company.com, .other.company.com
, requests tointernal.company.com
,foo.internal.company.com
, andother.company.com
will avoid the proxy. Requests tonotactuallyinternal.company.com
will still go via the proxy.Differences to other implementations:
Domain suffix vs. string suffix
wget and Python's urllib3 avoid the proxy if one of the
no_proxy
hosts is a string suffix of the request host, rather than a domain suffix (with special casing sono_proxy=.foo.example
avoids the proxy for requests tofoo.example
).Ignoring case/spaces
Some implementations ignore all spaces, rather than just
0x20
s following a comma. Some implementations also use case-sensitive domain handling.Port-specific rules
Ruby's stdlib implementation can be made to apply only to specific ports.
Avoiding the proxy for CADR ranges
Python's urllib3 allows you to specify e.g.
no_proxy=internal.company.com,192.168.0.0/16
.Avoiding the proxy for all requests
Ruby and cURL avoid the proxy for all requests if
no_proxy=*
is set.