blob: 7239438c491216e0c3a62e689fd8e300279e50d0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
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
|