diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-10-18 15:32:44 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-10-18 15:32:44 -0700 |
commit | 13655a4e394d69de48484c11fdf0d8e6981c8d94 (patch) | |
tree | 1334cf73205b9dfa885a5b734e385c419fb178db /actionpack/lib/action_dispatch | |
parent | b2debfb005cc6d0661b24c50983a885509f7f9c9 (diff) | |
download | rails-13655a4e394d69de48484c11fdf0d8e6981c8d94.tar.gz rails-13655a4e394d69de48484c11fdf0d8e6981c8d94.tar.bz2 rails-13655a4e394d69de48484c11fdf0d8e6981c8d94.zip |
move cache inside the instance so we do not need locking
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/http/headers.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/http/headers.rb b/actionpack/lib/action_dispatch/http/headers.rb index 9105da186f..dc04d4577b 100644 --- a/actionpack/lib/action_dispatch/http/headers.rb +++ b/actionpack/lib/action_dispatch/http/headers.rb @@ -3,10 +3,8 @@ module ActionDispatch class Headers include Enumerable - @@env_cache = Hash.new { |h,k| h[k] = "HTTP_#{k.upcase.gsub(/-/, '_')}" } - - def initialize(*args) - @headers = args.first || {} + def initialize(env = {}) + @headers = env end def [](header_name) @@ -26,11 +24,16 @@ module ActionDispatch end private - # Converts a HTTP header name to an environment variable name if it is - # not contained within the headers hash. - def env_name(header_name) - @headers.include?(header_name) ? header_name : @@env_cache[header_name] - end + + # Converts a HTTP header name to an environment variable name if it is + # not contained within the headers hash. + def env_name(header_name) + @headers.include?(header_name) ? header_name : cgi_name(header_name) + end + + def cgi_name(k) + "HTTP_#{k.upcase.gsub(/-/, '_')}" + end end end end |