Jump to solution
Verify

The Fix

Upgrade to version 0.15.0 or later.

Based on closed encode/httpx issue #1253 · 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%.

Jump to Verify Open PR/Commit
@@ -74,7 +74,6 @@ except httpx.HTTPStatusError as exc: * DecodingError * TooManyRedirects - * RequestBodyUnavailable * HTTPStatusError * InvalidURL
repro.py
def upload_file(name): with open(name, "rb") as input_file: while True: chunk = input_file.read(4096) if not chunk: break yield chunk # This will fail on some kinds of redirect, or on digest auth httpx.post(data=upload_file("example.zip"))
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\nUpgrade to version 0.15.0 or later.\nWhen NOT to use: This fix should not be used if the application relies on the previous ContentStream behavior.\n\n

Why This Fix Works in Production

  • Trigger: * Change the `httpcore` API, so that we *only* have `httpcore.ByteStream`, which is an abstract base class with for a unified sync+async byte stream. Ie. it…
  • Mechanism: The ContentStream API was unclear and caused issues with request body replay
  • Why the fix works: Drops the ContentStream completely, refactoring the API to use plain byte streams instead. (first fixed release: 0.15.0).
Production impact:
  • 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 ContentStream API was unclear and caused issues with request body replay
  • Production symptom (often without a traceback): * Change the `httpcore` API, so that we *only* have `httpcore.ByteStream`, which is an abstract base class with for a unified sync+async byte stream. Ie. it exposes `__iter__`, `__aiter__`, `close`, `aclose` methods.

Proof / Evidence

  • GitHub issue: #1253
  • Fix PR: https://github.com/encode/httpx/pull/1295
  • First fixed release: 0.15.0
  • 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.60

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“Delightful write up Tom, as always! Sounds like a nice way to expose the API while not exposing the entire hierarchy of actual implementations (which…”
@florimondmanca · 2020-09-04 · source
“Thanks @florimondmanca - main thing here is just to try to explain what needs to change and why, before we expose an httpx.ByteStream interface”
@lovelydinosaur · 2020-09-07 · source
“Actually we may not need to merge httpcore.AsyncByteStream/httpcore.SyncByteStream in order to get where we're going here”
@lovelydinosaur · 2020-09-07 · source

Failure Signature (Search String)

  • * Change the `httpcore` API, so that we *only* have `httpcore.ByteStream`, which is an abstract base class with for a unified sync+async byte stream. Ie. it exposes `__iter__`,
  • Thanks @florimondmanca - main thing here is just to try to explain what needs to change and why, before we expose an `httpx.ByteStream` interface.
Copy-friendly signature
signature.txt
Failure Signature ----------------- * Change the `httpcore` API, so that we *only* have `httpcore.ByteStream`, which is an abstract base class with for a unified sync+async byte stream. Ie. it exposes `__iter__`, `__aiter__`, `close`, `aclose` methods. Thanks @florimondmanca - main thing here is just to try to explain what needs to change and why, before we expose an `httpx.ByteStream` interface.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- * Change the `httpcore` API, so that we *only* have `httpcore.ByteStream`, which is an abstract base class with for a unified sync+async byte stream. Ie. it exposes `__iter__`, `__aiter__`, `close`, `aclose` methods. Thanks @florimondmanca - main thing here is just to try to explain what needs to change and why, before we expose an `httpx.ByteStream` interface.

Minimal Reproduction

repro.py
def upload_file(name): with open(name, "rb") as input_file: while True: chunk = input_file.read(4096) if not chunk: break yield chunk # This will fail on some kinds of redirect, or on digest auth httpx.post(data=upload_file("example.zip"))

What Broke

Users experienced failures when trying to stream content during redirects or authentication.

Why It Broke

The ContentStream API was unclear and caused issues with request body replay

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

Upgrade to version 0.15.0 or later.

When NOT to use: This fix should not be used if the application relies on the previous ContentStream behavior.

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/1295

First fixed release: 0.15.0

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be used if the application relies on the previous ContentStream behavior.

Verify Fix

verify
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

VersionStatus
0.15.0 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.