Skip to content

Fix environment proxies - #2741

Merged
lovelydinosaur merged 8 commits into
encode:masterfrom
karpetrosyan:fix-environment-proxies
Dec 14, 2023
Merged

Fix environment proxies#2741
lovelydinosaur merged 8 commits into
encode:masterfrom
karpetrosyan:fix-environment-proxies

Conversation

@karpetrosyan

@karpetrosyankarpetrosyan commented Jun 8, 2023

Copy link
Copy Markdown
Contributor

Now the httpx parses NO_PROXY: http://google.com to {'all://*http://google.com': None} but expected {'http://google.com': None}

TODO

  • Write a failing test
  • Make the test pass

@karpetrosyan
karpetrosyanforce-pushed the fix-environment-proxies branch from e27fee0 to fc9952fCompareJune 8, 2023 07:59
@karpetrosyan

Copy link
Copy Markdown
ContributorAuthor

Also, our documentation is now incorrect; according to https://www.python-httpx.org/environment_variables/#no_proxy, we can use scheme filtering with the NO_PROXY environment variable, which we cannot.

@karpetrosyan

Copy link
Copy Markdown
ContributorAuthor

Docs

export HTTP_PROXY=http://my-external-proxy.com:1234
export NO_PROXY=http://127.0.0.1,python-httpx.org
# As in the previous example, this request will be sent through the proxy
python -c "import httpx; httpx.get('http://example.com')"
# These requests will be sent directly, bypassing the proxy
python -c "import httpx; httpx.get('http://127.0.0.1:5000/my-api')" <- # This is not correct!
python -c "import httpx; httpx.get('https://www.python-httpx.org')"

@karpetrosyan
karpetrosyan requested a review from a teamJune 9, 2023 11:34
@lovelydinosaur

Copy link
Copy Markdown
Contributor

Excellent, yep. Apologies for the delay.

Let's get a CHANGELOG entry and pull this in. 👍

(Maybe this?... "Handle NO_PROXY envvar cases when a fully qualified URL is supplied as the value.")

@karpetrosyan

Copy link
Copy Markdown
ContributorAuthor

Done!

@lovelydinosaur
lovelydinosaur merged commit 3b9060e into encode:masterDec 14, 2023
@karpetrosyankarpetrosyan mentioned this pull request Dec 18, 2023
samclearman pushed a commit to titanmsp/httpx that referenced this pull request Apr 26, 2025
* Add red test
* Make the test pass
* Lint
* chanelog
---------
Co-authored-by: Karen Petrosyan <92274156+karosis88@users.noreply.github.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@karpetrosyan@lovelydinosaur