HTTPTransport doesn't detect HTTPS_PROXY #1635
Replies: 2 comments 1 reply
-
Heya Wes. That's right, yup. An When you use So, suppose you had: HTTPS_PROXY="http://127.0.0.1:1234" Then you'd end up with the equivalent of... client = httpx.Client(
mounts={
"https://": httpx.HTTPTransport(proxy=httpx.Proxy("http://127.0.0.1:1234")),
"http://": httpx.HTTPTransport(),
}
) There's more complex cases if I'm not quite sure that I know how best to document/explain this, but transport instances either use a proxy or don't, so we don't apply the environment settings at that level because they're more complexly expressive that just ON/OFF. Instead the settings apply at the level of the client, which can then mount one or more correctly configured transports. I'd be curious to understand more about why they're using this style... import httpx
url = "http://example.com"
with httpx.Client(transport=httpx.HTTPTransport()) as client:
print(client.get(url)) Rather than this style... import httpx
url = "http://example.com"
with httpx.Client() as client:
print(client.get(url)) |
Beta Was this translation helpful? Give feedback.
-
I also tried to raise this issue in #2593 but was ignored at the time. I think the documentation could be more explicit for this case. |
Beta Was this translation helpful? Give feedback.
-
I'm using another Python library that utilizes httpx to fetch a remote resource. The code they use is of the form (as a minimal example):
This fails when utilizing a proxy, even though I have
HTTPS_PROXY
set, with the error:The following variations do work (
HTTPTransport
isn't used or, if it is used, the proxy is set manually):Beta Was this translation helpful? Give feedback.
All reactions