Respect no_proxy environment variable#2171
Open
Sanjays2402 wants to merge 1 commit into
Open
Conversation
An explicitly configured proxy was used for every request, even when the target host matched the no_proxy / NO_PROXY environment variable. Add a _proxies_for_url helper that returns an empty proxy mapping for bypassed hosts so libcloud behaves consistently with other HTTP clients.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Respect no_proxy environment variable
Description
Fixes #2077.
When a proxy is configured explicitly (via
set_http_proxy()or thehttp_proxy/https_proxyenvironment variables), libcloud used it for every request, includinghosts listed in
no_proxy/NO_PROXY. Other HTTP clients (curl, requests via itsown env handling, urllib) all honour
no_proxy, so this was surprising and made itimpossible to talk to an internal endpoint directly while a proxy was configured.
This adds a
_proxies_for_url(url)helper onLibcloudBaseConnectionthat returnsan empty proxy mapping (
{}) when the target host matchesno_proxy, andNoneotherwise so the session default applies. It is passed as
proxies=inLibcloudConnection.request(). Matching is delegated torequests.utils.should_bypass_proxies,so libcloud inherits the exact same
no_proxysemantics as requests rather thanreimplementing them.
Status
done, ready for review
Checklist (tick everything that applies)