Use correct HTTP status codes for blackist and throttle

This commit is contained in:
Alex Volkovitsky & Sachin Maharjan 2013-06-28 10:55:28 -07:00
parent 237dc2d944
commit cfbee2c552

View file

@ -39,10 +39,10 @@ module Rack::Attack
# Set defaults
@notifier ||= ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
@blacklisted_response ||= lambda {|env| [503, {}, ["Blocked\n"]] }
@blacklisted_response ||= lambda {|env| [401, {}, ["Unauthorized\n"]] }
@throttled_response ||= lambda {|env|
retry_after = env['rack.attack.match_data'][:period] rescue nil
[503, {'Retry-After' => retry_after.to_s}, ["Retry later\n"]]
[429, {'Retry-After' => retry_after.to_s}, ["Retry later\n"]]
}
self