Repository navigation
ratelimit: parse Retry-After HTTP dates in IMF-fixdate format - #1216
Merged
Merged
Conversation
parseTime tried time.RFC850 and time.RFC3339 for non-numeric reset
values. RFC 9110 HTTP dates are usually IMF-fixdate
("Sun, 06 Nov 1994 08:49:37 GMT"), which neither layout accepts, so a
429 with an HTTP-date Retry-After fell back to the 60 second default.
Use http.ParseTime, which accepts IMF-fixdate, RFC 850 and ANSI C, and
keep the RFC3339 fallback.
haroonkhan-c1
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
parseTimeinpkg/ratelimit/http.gohandles non-numeric reset values withtime.RFC850and thentime.RFC3339. The usual HTTP-date form forRetry-Afteris IMF-fixdate (Sun, 06 Nov 1994 08:49:37 GMT, RFC 9110 section 5.6.7), and neither layout accepts it. So a 429 withRetry-After: <IMF-fixdate>fails to parse,ExtractRateLimitDataskips the header, and the connector gets the 60 second default instead of the server's reset time.This switches the first attempt to
http.ParseTime, which accepts IMF-fixdate, RFC 850 and ANSI C, and keeps the RFC3339 fallback.Testing:
TestExtractRateLimitData_RetryAfterHTTPDatecovering all three HTTP-date formats on a 429. The IMF-fixdate and ANSI C cases fail on main (reset comes back as now+60s) and pass with the change.go test ./pkg/ratelimit/ ./pkg/uhttp/passes.golangci-lint run ./pkg/ratelimit/...reports 0 issues.I used AI assistance while writing this and checked the change and tests by hand.