Skip to content

Add retry_request / aretry_request helpers for body-phase errors - #79

Merged
will-ockmore merged 3 commits into
mainfrom
read-retry-helper
Jul 6, 2026
Merged

Add retry_request / aretry_request helpers for body-phase errors#79
will-ockmore merged 3 commits into
mainfrom
read-retry-helper

Conversation

@will-ockmore

Copy link
Copy Markdown
Owner

feat: add retry_request / aretry_request helpers for body-phase errors

HTTPX transports return once response headers arrive, so errors raised while reading the body (ReadTimeout, truncated RemoteProtocolError) bypass RetryTransport and are never retried. These helpers run the retry loop at the client level, where the body is read, closing that gap with the same Retry configuration.

  • Extract the retry loop to module-level _retry_operation(_async) shared by RetryTransport and the helpers.
  • retry_request / aretry_request: retry header-phase errors, retryable status codes, and body-phase errors for buffered (non-streaming) requests.
  • Honour Retry.allowed_methods (idempotent-only by default); forward auth / follow_redirects to client.send; raise if the client already uses RetryTransport (would retry twice).
  • Docs: FAQ explains the niche and when to prefer RetryTransport; README pointer and API docstrings link to it.

Additionally, backfill CHANGELOG for the helpers, validate_response, request.extensions["retry"], and Retry.copy_with.

Closes #29

@will-ockmore will-ockmore changed the title Read retry helper Add retry_request / aretry_request helpers for body-phase errors Jun 23, 2026
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e9c1c5d) to head (ea032d2).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              main       #79    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files            6         8     +2     
  Lines         1220      1460   +240     
==========================================
+ Hits          1220      1460   +240     
Files with missing lines Coverage Δ
httpx_retries/__init__.py 100.00% <100.00%> (ø)
httpx_retries/helpers.py 100.00% <100.00%> (ø)
httpx_retries/transport.py 100.00% <100.00%> (ø)
tests/test_helpers.py 100.00% <100.00%> (ø)
tests/test_transport.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@will-ockmore will-ockmore self-assigned this Jun 23, 2026
@will-ockmore
will-ockmore merged commit 0abe0d8 into main Jul 6, 2026
7 checks passed
@will-ockmore
will-ockmore deleted the read-retry-helper branch July 6, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retries on response.read and response.aread can't be handled inside RetryTransport

1 participant