Python developer resource
Missing elapsed time on a buffered HTTPX response?
A small compatibility wrapper for custom sync and async transports returning responses that are already buffered, closed, and consumed. Includes a standalone module, offline demo, and regression tests.
Download the Python files (ZIP)MIT-licensed example files. No signup or payment. Tested locally with Python 3.12 and HTTPX 0.28.1 only.
A workaround, not an upstream fix
As of November 11, 2026, HTTPX issue #3712 is open and PR #3757 is open and unmerged. HTTPX 0.28.1 is the latest stable release checked on that date. Recheck upstream before adopting this workaround.
The fallback zero means timing is unavailable. It is never a latency measurement. Exclude fallback values from latency reports and performance comparisons.
Start with the simplest option
If you own a test fixture and only need a synthetic response to expose an elapsed value, set it directly when constructing the fixture:
from datetime import timedelta
import httpx
response = httpx.Response(200, content=b"fixture")
response.elapsed = timedelta(0) # Timing unavailable, not latency.See the existing zero-value fixture workaround. You do not need another wrapper just for this.
Use the downloaded wrapper when you need that policy at a custom transport boundary across multiple responses, in sync or async clients. It preserves an elapsed value already supplied by the transport and only adds a zero fallback when the value is missing on an already closed and consumed response.
The upstream review on preserving timings explains why existing values should survive. This wrapper does not measure network time, change streaming responses, or replace an upstream release.
The module exports BufferedElapsedTransport and AsyncBufferedElapsedTransport. Use ELAPSED_PLACEHOLDER_EXTENSION to identify the fallback marker in response.extensions; see the README for the exact check.
Run it locally
Extract the ZIP into a local folder. It contains httpx_buffered_elapsed.py, test_httpx_buffered_elapsed.py, README.md, and LICENSE.txt. The MIT license covers only these example files, not the company repository. Read the README for sync and async usage from the downloaded module.
Use your local Python environment, preferably a virtual environment. The example was tested against HTTPX 0.28.1; the tests also require pytest. If you are setting up an isolated test environment, install these dependencies there:
python -m pip install "httpx==0.28.1" pytestFrom the extracted folder, run the offline demo and tests. Dependency installation needs package access; the demo itself does not make network requests.
python httpx_buffered_elapsed.py
python -m pytest test_httpx_buffered_elapsed.py -qReview the code and run your own transport tests before using it. Compatibility beyond the tested Python and HTTPX versions has not been verified. Do not downgrade a working application just for this example.