Skip to content

Respect no_proxy environment variable#2171

Open
Sanjays2402 wants to merge 1 commit into
apache:trunkfrom
Sanjays2402:fix/2077-respect-no-proxy
Open

Respect no_proxy environment variable#2171
Sanjays2402 wants to merge 1 commit into
apache:trunkfrom
Sanjays2402:fix/2077-respect-no-proxy

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

Respect no_proxy environment variable

Description

Fixes #2077.

When a proxy is configured explicitly (via set_http_proxy() or the http_proxy /
https_proxy environment variables), libcloud used it for every request, including
hosts listed in no_proxy / NO_PROXY. Other HTTP clients (curl, requests via its
own env handling, urllib) all honour no_proxy, so this was surprising and made it
impossible to talk to an internal endpoint directly while a proxy was configured.

This adds a _proxies_for_url(url) helper on LibcloudBaseConnection that returns
an empty proxy mapping ({}) when the target host matches no_proxy, and None
otherwise so the session default applies. It is passed as proxies= in
LibcloudConnection.request(). Matching is delegated to requests.utils.should_bypass_proxies,
so libcloud inherits the exact same no_proxy semantics as requests rather than
reimplementing them.

Status

done, ready for review

Checklist (tick everything that applies)

  • Code linting (required, can be done after the PR checks)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Respect no_proxy environment variable

1 participant