Skip to content

Commit

Permalink
Merge pull request ruby-grape#1055 from marshall-lee/remove_case_inse…
Browse files Browse the repository at this point in the history
…nsitive_accept

Remove case insensitive Accept header support
  • Loading branch information
dblock committed Jul 3, 2015
2 parents c87187f + ef3ef47 commit 735034b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
1 change: 0 additions & 1 deletion lib/grape/http/headers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module Headers
HTTP_TRANSFER_ENCODING = 'HTTP_TRANSFER_ENCODING'.freeze
HTTP_ACCEPT = 'HTTP_ACCEPT'.freeze

ACCEPT = 'accept'.freeze
FORMAT = 'format'.freeze
end
end
Expand Down
9 changes: 1 addition & 8 deletions lib/grape/middleware/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ def default_options
}
end

def headers
env.dup.inject({}) do |h, (k, v)|
h[k.to_s.downcase[5..-1]] = v if k.to_s.downcase.start_with?('http_')
h
end
end

def before
negotiate_content_type
read_body_input
Expand Down Expand Up @@ -133,7 +126,7 @@ def format_from_header
end

def mime_array
accept = headers[Grape::Http::Headers::ACCEPT]
accept = env[Grape::Http::Headers::HTTP_ACCEPT]
return [] unless accept

accept_into_mime_and_quality = %r{
Expand Down
5 changes: 0 additions & 5 deletions spec/grape/middleware/formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ def to_xml
expect(subject.env['api.format']).to eq(:xml)
end

it 'looks for case-indifferent headers' do
subject.call('PATH_INFO' => '/info', 'http_accept' => 'application/xml')
expect(subject.env['api.format']).to eq(:xml)
end

it 'uses quality rankings to determine formats' do
subject.call('PATH_INFO' => '/info', 'HTTP_ACCEPT' => 'application/json; q=0.3,application/xml; q=1.0')
expect(subject.env['api.format']).to eq(:xml)
Expand Down

0 comments on commit 735034b

Please sign in to comment.