aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/headers.rb
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2014-05-07 12:01:34 -0500
committerschneems <richard.schneeman@gmail.com>2014-05-07 12:01:34 -0500
commitca97ec509955d70bde47d337e5086920f0c79b63 (patch)
treeebc92027607789b0cd1a777c32dfdda54ed08789 /actionpack/lib/action_dispatch/http/headers.rb
parent98baa827ac5e3a7e0fd427febed066d013198371 (diff)
downloadrails-ca97ec509955d70bde47d337e5086920f0c79b63.tar.gz
rails-ca97ec509955d70bde47d337e5086920f0c79b63.tar.bz2
rails-ca97ec509955d70bde47d337e5086920f0c79b63.zip
HTTP::Headers#key? correctly converts
Previously if you were looking for a given key, the header may incorrectly tell you that it did not exist even though it would return a valid value: ```ruby env = { "CONTENT_TYPE" => "text/plain" } headers = ActionDispatch::Http::Headers.new(env) headers["Content-Type"] # => "text/plain" headers.key?("Content-Type") # => false ``` This PR fixes that behavior by converting the key before checking for presence
Diffstat (limited to 'actionpack/lib/action_dispatch/http/headers.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/headers.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/headers.rb b/actionpack/lib/action_dispatch/http/headers.rb
index 2666cd4b0a..788eed8b89 100644
--- a/actionpack/lib/action_dispatch/http/headers.rb
+++ b/actionpack/lib/action_dispatch/http/headers.rb
@@ -26,7 +26,9 @@ module ActionDispatch
@env[env_name(key)] = value
end
- def key?(key); @env.key? key; end
+ def key?(key)
+ @env.key? env_name(key)
+ end
alias :include? :key?
def fetch(key, *args, &block)