Skip to content

Add the Retry-After header to the rate limit filter responses - #1171

Open
arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:ratelimit-retry-after
Open

arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:ratelimit-retry-after

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

When exposeHeaders is enabled, the RateLimitFilter now sends a Retry-After header (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 RateLimiter does not provide the delay. RateLimiter gets 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 with FastRateLimiter and ExactRateLimiter, HTTP/1.1 and HTTP/2, comparing with main.

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.
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