-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Currently, if I configure a rate limiter with the following code
r.Use(httprate.Limit(
10,
time.Minute,
httprate.WithResponseHeaders(httprate.ResponseHeaders{
Limit: "X-RateLimit-Limit",
Remaining: "X-RateLimit-Remaining",
Reset: "X-RateLimit-Reset",
RetryAfter: "Retry-After",
Increment: "", // omit
}),
))
After I hit the rate-limit, the Retry-After
header is added to the request, but the value is always set to the window length, (in this case 60 seconds)
If the client sends 10 requests spaced out by 2 seconds and then sends a 11th one (which the rate-limiter should catch), shouldn't the Retry-After
header contain 40
(the 10 first requests took 20 seconds to complete) instead of 60
, as the next request will be accepted 60 seconds after the initial request was made, not 60 seconds after the first failing request?
This would enable the client to wait for the exact time it needs to if it hits the rate limit.
Metadata
Metadata
Assignees
Labels
No labels