The Fix
Upgrade to version 0.7.2 or later.
Based on closed encode/httpx issue #149 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -20,7 +20,7 @@
```
-* `def __init__([auth], [cookies], [verify], [cert], [timeout], [pool_limits], [max_redirects], [app], [dispatch])`
+* `def __init__([auth], [headers], [cookies], [verify], [cert], [timeout], [pool_limits], [max_redirects], [app], [dispatch])`
* `def .get(url, [params], [headers], [cookies], [auth], [stream], [allow_redirects], [verify], [cert], [timeout])`
>> headers = Headers({"X-Auth-Token": "FooBarBazToken", "User-Agent": "python-myclient/0.2.1"})
>> session = Client(base_url="https://httpbin.org", headers=headers)
>> get_headers = session.get("/headers")
>> get_headers.json()
{'headers': {'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate',
'Cookie': 'MyCookie=MyValue',
'Host': 'httpbin.org',
'User-Agent': 'python-myclient/0.2.1',
'X-Auth-Token': 'FooBarBazToken'}}
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\nUpgrade to version 0.7.2 or later.\nWhen NOT to use: Do not use this fix if you require headers to be set differently for individual requests.\n\n
Why This Fix Works in Production
- Trigger: Users could not set headers for each request, impacting token-based authentication.
- Mechanism: The BaseClient class did not support setting headers for requests
- Why the fix works: Resolves #149 by adding `headers` as an argument to the `BaseClient` class, enabling users to set headers for each request. (first fixed release: 0.7.2).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- The BaseClient class did not support setting headers for requests
- Production symptom (often without a traceback): Users could not set headers for each request, impacting token-based authentication.
Proof / Evidence
- GitHub issue: #149
- Fix PR: https://github.com/encode/httpx/pull/159
- First fixed release: 0.7.2
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.55
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Indeed, yup! 👍 We've got a .cookies interface on there already, but we don't yet have a .headers interface.”
“So there is a cookies= option! I missed it because I was searching so hard for headers. I'll update the OP.”
Failure Signature (Search String)
- Users could not set headers for each request, impacting token-based authentication.
Copy-friendly signature
Failure Signature
-----------------
Users could not set headers for each request, impacting token-based authentication.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Users could not set headers for each request, impacting token-based authentication.
Minimal Reproduction
>> headers = Headers({"X-Auth-Token": "FooBarBazToken", "User-Agent": "python-myclient/0.2.1"})
>> session = Client(base_url="https://httpbin.org", headers=headers)
>> get_headers = session.get("/headers")
>> get_headers.json()
{'headers': {'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate',
'Cookie': 'MyCookie=MyValue',
'Host': 'httpbin.org',
'User-Agent': 'python-myclient/0.2.1',
'X-Auth-Token': 'FooBarBazToken'}}
What Broke
Users could not set headers for each request, impacting token-based authentication.
Why It Broke
The BaseClient class did not support setting headers for requests
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 0.7.2 or later.
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/encode/httpx/pull/159
First fixed release: 0.7.2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if you require headers to be set differently for individual requests.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
- Upgrade behind a canary and run integration tests against the canary before 100% rollout.
Version Compatibility Table
| Version | Status |
|---|---|
| 0.7.2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.