Repository navigation
Add the Retry-After header to the rate limit filter responses - #1171
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
When exposeHeaders is enabled, send a Retry-After header with the 429 responses sent by the RateLimitFilter when the limit is enforced. The value is the time until the end of the current time bucket, rounded up to whole seconds. The header is omitted if the delay is not known, for example if the time bucket changed while the request was being counted or if a custom RateLimiter does not provide it. RateLimiter gets a default method for this, so existing implementations keep working.
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.
When
exposeHeadersis enabled, theRateLimitFilternow sends aRetry-Afterheader (RFC 9110, section 10.2.3) with the 429 responses it sends when the limit is enforced (RFC 6585, section 4). The value is the time until the end of the current time bucket, rounded up to whole seconds. Nothing changes by default.The header is omitted if the delay is not known. That is the case if the time bucket changed while the request was being counted, as it is then not known which bucket counted the request, and if a custom
RateLimiterdoes not provide the delay.RateLimitergets a default method for this, so existing implementations keep working.Tests:
TestRateLimitFilterRetryAfter,TestRateLimiterRetryAfter, and the existing rate limit filter tests. Also run against a running Tomcat withFastRateLimiterandExactRateLimiter, HTTP/1.1 and HTTP/2, comparing with main.