mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
Prefer to not use X- style headers for clarity
The IETF decided the X- style custom headers have caused more headache than the value: https://tools.ietf.org/html/rfc6648 so this tool (which is very popular and much loved) shouldn't suggest using an old style.
This commit is contained in:
parent
516660b55c
commit
3e5a4607cd
1 changed files with 4 additions and 4 deletions
|
|
@ -300,7 +300,7 @@ end
|
|||
While Rack::Attack's primary focus is minimizing harm from abusive clients, it
|
||||
can also be used to return rate limit data that's helpful for well-behaved clients.
|
||||
|
||||
Here's an example response that includes conventional `X-RateLimit-*` headers:
|
||||
Here's an example response that includes conventional `RateLimit-*` headers:
|
||||
|
||||
```ruby
|
||||
Rack::Attack.throttled_response = lambda do |env|
|
||||
|
|
@ -308,9 +308,9 @@ Rack::Attack.throttled_response = lambda do |env|
|
|||
now = match_data[:epoch_time]
|
||||
|
||||
headers = {
|
||||
'X-RateLimit-Limit' => match_data[:limit].to_s,
|
||||
'X-RateLimit-Remaining' => '0',
|
||||
'X-RateLimit-Reset' => (now + (match_data[:period] - now % match_data[:period])).to_s
|
||||
'RateLimit-Limit' => match_data[:limit].to_s,
|
||||
'RateLimit-Remaining' => '0',
|
||||
'RateLimit-Reset' => (now + (match_data[:period] - now % match_data[:period])).to_s
|
||||
}
|
||||
|
||||
[ 429, headers, ["Throttled\n"]]
|
||||
|
|
|
|||
Loading…
Reference in a new issue