Default responses: add Content-Type header

Fixes #68
This commit is contained in:
Aaron Suggs 2014-05-21 18:33:20 -04:00
parent 1fbcb479f1
commit 6f7bd66dfa
2 changed files with 3 additions and 2 deletions

View file

@ -1,6 +1,7 @@
# Changlog
## master (unreleased)
- Default throttled/blacklist responses have Content-Type: text/plain
- Rack::Attack.clear! resets tracks
## v4.0.1 - 14 May 2014

View file

@ -80,10 +80,10 @@ class Rack::Attack
# Set defaults
@notifier = ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
@blacklisted_response = lambda {|env| [403, {}, ["Forbidden\n"]] }
@blacklisted_response = lambda {|env| [403, {'Content-Type' => 'text/plain'}, ["Forbidden\n"]] }
@throttled_response = lambda {|env|
retry_after = env['rack.attack.match_data'][:period] rescue nil
[429, {'Retry-After' => retry_after.to_s}, ["Retry later\n"]]
[429, {'Content-Type' => 'text/plain', 'Retry-After' => retry_after.to_s}, ["Retry later\n"]]
}
def initialize(app)