diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-18 15:10:41 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-18 15:10:41 +0300 |
commit | f23a9a17ed6237c346d2e9210c6841e319e8d030 (patch) | |
tree | 7b46c0ff193c445f35774a86ec3d0ff000d2ff77 /lib/gitlab/rack_attack.rb | |
parent | d7432b66ff241af3f39d82da581832a084983378 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/rack_attack.rb')
-rw-r--r-- | lib/gitlab/rack_attack.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/gitlab/rack_attack.rb b/lib/gitlab/rack_attack.rb index 0595d0a7e5b..2a94fb91880 100644 --- a/lib/gitlab/rack_attack.rb +++ b/lib/gitlab/rack_attack.rb @@ -49,9 +49,9 @@ module Gitlab # reset. This is a standardized HTTP header: # https://tools.ietf.org/html/rfc7231#page-69 # - # - RateLimit-Reset: Similar to Retry-After. + # - RateLimit-Reset: the point of time that the request quota is reset, in Unix time # - # - RateLimit-ResetTime: the point of time that the quest quota is reset. + # - RateLimit-ResetTime: the point of time that the request quota is reset, in HTTP date format def self.throttled_response_headers(matched, match_data) # Match data example: # {:discriminator=>"127.0.0.1", :count=>12, :period=>60 seconds, :limit=>1, :epoch_time=>1609833930} @@ -62,14 +62,14 @@ module Gitlab observed = match_data[:count] now = match_data[:epoch_time] retry_after = period - (now % period) - reset_time = now + (period - now % period) + reset_time = Time.at(now + retry_after) # rubocop:disable Rails/TimeZone { 'RateLimit-Name' => matched.to_s, 'RateLimit-Limit' => rounded_limit.to_s, 'RateLimit-Observed' => observed.to_s, 'RateLimit-Remaining' => (limit > observed ? limit - observed : 0).to_s, - 'RateLimit-Reset' => retry_after.to_s, - 'RateLimit-ResetTime' => Time.at(reset_time).httpdate, + 'RateLimit-Reset' => reset_time.to_i.to_s, + 'RateLimit-ResetTime' => reset_time.httpdate, 'Retry-After' => retry_after.to_s } end |