mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-04-27 15:07:41 +00:00
Response header values must be strings
This commit is contained in:
parent
4a3faa4b1b
commit
8e59e84e00
2 changed files with 2 additions and 2 deletions
|
|
@ -35,7 +35,7 @@ module Rack::Attack
|
||||||
@blacklisted_response ||= lambda {|env| [503, {}, ['Blocked']] }
|
@blacklisted_response ||= lambda {|env| [503, {}, ['Blocked']] }
|
||||||
@throttled_response ||= lambda {|env|
|
@throttled_response ||= lambda {|env|
|
||||||
retry_after = env['rack.attack.match_data'][:period] rescue nil
|
retry_after = env['rack.attack.match_data'][:period] rescue nil
|
||||||
[503, {'Retry-After' => retry_after}, ['Retry later']]
|
[503, {'Retry-After' => retry_after.to_s}, ['Retry later']]
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ describe 'Rack::Attack' do
|
||||||
last_request.env['rack.attack.match_data'].must_equal({:count => 2, :limit => 1, :period => 1})
|
last_request.env['rack.attack.match_data'].must_equal({:count => 2, :limit => 1, :period => 1})
|
||||||
end
|
end
|
||||||
it 'should set a Retry-After header' do
|
it 'should set a Retry-After header' do
|
||||||
last_response.headers['Retry-After'].must_equal 1
|
last_response.headers['Retry-After'].must_equal '1'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue