Repository navigation
A loopback target is not enough to isolate a client test from proxy settings #3894
cooldk
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
While building a local SDK test harness, I wanted to distinguish requests reaching its fake origin from requests sent to a proxy. I operate Kunavo; this write-up and the test were prepared with AI assistance.
With HTTPX 0.29.0, I ran four synchronous requests against two local HTTP servers: an origin and a synthetic proxy that only returns a label, never forwards traffic. An explicit fixture
HTTP_PROXYpointed to the latter.NO_PROXYtrust_env=False127.0.0.1trust_env=False, proxy=fixture_proxyThis follows the documented environment-variable policy. In particular,
trust_env=Falsedoes not cancel an explicit proxy argument. For a deliberately isolated local test, specify its transport/environment policy and count requests at the test server rather than assuming the hostname proves where the request went.The December 5 run used Python 3.12.13, an otherwise cleared subprocess environment and a Python socket guard allowing only those two loopback endpoints. Nine assertions passed; no other connection was attempted. No real credentials or paid API calls were used.
This is an HTTPX usage demonstration, not a feature request or a claim about hip. It does not test HTTPS, certificate stores, HTTP/2, retry behavior or live SDK integration. Disabling environment configuration is a test choice, not a recommendation to discard an organization's proxy or certificate policy.
Complete local reproducer
Save the following as
proxy_boundary.py. Setup downloads the named public dependencies; the test itself uses only the synthetic/local inputs described above.python3 -m venv .venv .venv/bin/python -m pip install httpx==0.29.0 env -i PATH=/usr/bin:/bin "$PWD/.venv/bin/python" -I proxy_boundary.pyAll reactions