Skip to content

Commit e159056

Browse files
author
Michael Bleigh
committed
Allow nil HTTP_ACCEPT header in header strategy.
1 parent 05158c7 commit e159056

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/grape/middleware/versioner/header.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module Versioner
2323
# route.
2424
class Header < Base
2525
def before
26-
accept = env['HTTP_ACCEPT']
26+
accept = env['HTTP_ACCEPT'] || ""
2727

2828
if options[:version_options] && options[:version_options].keys.include?(:strict) && options[:version_options][:strict]
2929
if (accept.nil? || accept.empty?) && options[:versions] && options[:version_options][:using] == :header

spec/grape/middleware/versioner/header_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
:version_options => {:using => :header}
5858
}
5959
subject.call('HTTP_ACCEPT' => '').first.should == 200
60+
subject.call({}).first.should == 200
6061
end
6162

6263
it 'should return a 200 when no header is set but strict header based versioning is disabled' do
@@ -65,6 +66,7 @@
6566
:version_options => {:using => :header, :strict => false}
6667
}
6768
subject.call('HTTP_ACCEPT' => '').first.should == 200
69+
subject.call({}).first.should == 200
6870
end
6971

7072
it 'should return a 404 when no header is set but strict header based versioning is used' do

0 commit comments

Comments
 (0)