Skip to content

Commit a1cedbb

Browse files
committed
Merge pull request rack#93 from gsamokovarov/dont-rescue-nil
Avoid rescue nil in the default throttled response
2 parents 7781e3a + f737dbb commit a1cedbb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/rack/attack.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def clear!
8282
@notifier = ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
8383
@blacklisted_response = lambda {|env| [403, {'Content-Type' => 'text/plain'}, ["Forbidden\n"]] }
8484
@throttled_response = lambda {|env|
85-
retry_after = env['rack.attack.match_data'][:period] rescue nil
85+
retry_after = (env['rack.attack.match_data'] || {})[:period]
8686
[429, {'Content-Type' => 'text/plain', 'Retry-After' => retry_after.to_s}, ["Retry later\n"]]
8787
}
8888

0 commit comments

Comments
 (0)