Skip to content

Retry HTTP 429 responses (httpbin.org rate limit) - #3

Merged
endurodave merged 1 commit into
mainfrom
fix/rate-limit-retry
Nov 22, 2026
Merged

endurodave merged 1 commit into
mainfrom
fix/rate-limit-retry

Conversation

@endurodave

Copy link
Copy Markdown
Member

httpbin.org now limits each client to 2 requests per second and answers the rest with 429 Too Many Requests. The unit tests send requests about 10 ms apart. On the fast Ubuntu runner, Callback.cpp's POST test got the 429 body instead of the echo and failed its "sensor" check at line 104. That happened on PR #2 and again after the merge on main.

  • Retry: AsyncHttp retries a 429 up to 3 times on the worker thread. It waits for the server's Retry-After (capped at 5 s) or 1 s, then returns the last response.
  • Setting: SetRateLimitRetry(maxRetries, retryDelay) changes the retry count and delay; 0 retries turns it off. The @note says a rate-limited request holds up the requests queued behind it.
  • Refactor: HttpGet/HttpPost share the request loop in a private Perform().
  • Test: Blocking.cpp Test 7 sends httpbin.org/status/429. It checks that the request is retried (time taken ≥ 2 × delay), then returned as a 429, and that 0 returns it at once.
  • Diagnostics: the POST callback test prints the status, error and body when it fails, instead of a bare assert.

🤖 Generated with Claude Code

httpbin.org now limits clients to 2 requests per second and answers
the rest with 429 Too Many Requests. The tests send requests about
10 ms apart, so on the fast Ubuntu runner Callback.cpp's POST test got
the 429 body and failed its "sensor" check.

- AsyncHttp retries a 429 up to 3 times, waiting for Retry-After
  (capped at 5 s) or 1 s. SetRateLimitRetry() changes or disables it.
- HttpGet/HttpPost share the request loop in Perform().
- New test: httpbin.org/status/429 is retried, then returned.
- The POST callback test prints the status, error and body on failure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@endurodave
endurodave merged commit 253d596 into main Nov 22, 2026
3 checks passed
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.

1 participant