Skip to content
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

Fix environment proxies #2741

Merged
merged 8 commits into from Dec 14, 2023

Conversation

karpetrosyan
Copy link
Member

@karpetrosyan karpetrosyan commented Jun 8, 2023

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
Copy link
Member Author

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
Member Author

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 team June 9, 2023 11:34
@tomchristie
Copy link
Member

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
Member Author

Done!

@tomchristie tomchristie merged commit 3b9060e into encode:master Dec 14, 2023
5 checks passed
@karpetrosyan karpetrosyan mentioned this pull request Dec 18, 2023
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.

None yet

2 participants