Skip to content

Commit 735034b

Browse files
committed
Merge pull request #1055 from marshall-lee/remove_case_insensitive_accept
Remove case insensitive Accept header support
2 parents c87187f + ef3ef47 commit 735034b

File tree

3 files changed

+1
-14
lines changed

3 files changed

+1
-14
lines changed

lib/grape/http/headers.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module Headers
2020
HTTP_TRANSFER_ENCODING = 'HTTP_TRANSFER_ENCODING'.freeze
2121
HTTP_ACCEPT = 'HTTP_ACCEPT'.freeze
2222

23-
ACCEPT = 'accept'.freeze
2423
FORMAT = 'format'.freeze
2524
end
2625
end

lib/grape/middleware/formatter.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ def default_options
1111
}
1212
end
1313

14-
def headers
15-
env.dup.inject({}) do |h, (k, v)|
16-
h[k.to_s.downcase[5..-1]] = v if k.to_s.downcase.start_with?('http_')
17-
h
18-
end
19-
end
20-
2114
def before
2215
negotiate_content_type
2316
read_body_input
@@ -133,7 +126,7 @@ def format_from_header
133126
end
134127

135128
def mime_array
136-
accept = headers[Grape::Http::Headers::ACCEPT]
129+
accept = env[Grape::Http::Headers::HTTP_ACCEPT]
137130
return [] unless accept
138131

139132
accept_into_mime_and_quality = %r{

spec/grape/middleware/formatter_spec.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ def to_xml
110110
expect(subject.env['api.format']).to eq(:xml)
111111
end
112112

113-
it 'looks for case-indifferent headers' do
114-
subject.call('PATH_INFO' => '/info', 'http_accept' => 'application/xml')
115-
expect(subject.env['api.format']).to eq(:xml)
116-
end
117-
118113
it 'uses quality rankings to determine formats' do
119114
subject.call('PATH_INFO' => '/info', 'HTTP_ACCEPT' => 'application/json; q=0.3,application/xml; q=1.0')
120115
expect(subject.env['api.format']).to eq(:xml)

0 commit comments

Comments
 (0)