mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
104f31af1d
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8625 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
31 lines
No EOL
660 B
Ruby
31 lines
No EOL
660 B
Ruby
module ActionController
|
|
module Http
|
|
class Headers < ::Hash
|
|
|
|
def initialize(constructor = {})
|
|
if constructor.is_a?(Hash)
|
|
super()
|
|
update(constructor)
|
|
else
|
|
super(constructor)
|
|
end
|
|
end
|
|
|
|
def [](header_name)
|
|
if include?(header_name)
|
|
super
|
|
else
|
|
super(normalize_header(header_name))
|
|
end
|
|
end
|
|
|
|
|
|
private
|
|
# Takes an HTTP header name and returns it in the
|
|
# format
|
|
def normalize_header(header_name)
|
|
"HTTP_#{header_name.upcase.gsub(/-/, '_')}"
|
|
end
|
|
end
|
|
end
|
|
end |