File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ def format_headers_for_sentry(env_hash)
101101 # env['SERVER_PROTOCOL']. But we don't want to ignore a valid header
102102 # if the request has legitimately sent a Version header themselves.
103103 # See: https://github.com/rack/rack/blob/028438f/lib/rack/handler/cgi.rb#L29
104- next if key == 'HTTP_VERSION' && value == ENV [ 'SERVER_PROTOCOL' ]
104+ next if key == 'HTTP_VERSION' && value == env_hash [ 'SERVER_PROTOCOL' ]
105105
106106 next unless key . start_with? ( 'HTTP_' ) || %w( CONTENT_TYPE CONTENT_LENGTH ) . include? ( key )
107107 # Rack stores headers as HTTP_WHAT_EVER, we need What-Ever
Original file line number Diff line number Diff line change 8484 stack . call ( env )
8585 end
8686
87+ it 'transforms headers to conform with the interface' do
88+ env = { "SERVER_PROTOCOL" => "HTTP/1.1" , "HTTP_FOO" => "BAR" , "HTTP_VERSION" => "HTTP/1.1" }
89+
90+ interface = Raven ::HttpInterface . new
91+ interface . from_rack ( env )
92+
93+ expect ( interface . headers [ "Foo" ] ) . to eq ( "BAR" )
94+ expect ( interface . headers [ "Version" ] ) . to be_nil
95+ end
96+
97+ it 'does not ignore version headers which do not match SERVER_PROTOCOL' do
98+ env = { "SERVER_PROTOCOL" => "HTTP/1.1" , "HTTP_VERSION" => "HTTP/2.0" }
99+
100+ interface = Raven ::HttpInterface . new
101+ interface . from_rack ( env )
102+
103+ expect ( interface . headers [ "Version" ] ) . to eq ( "HTTP/2.0" )
104+ end
105+
87106 it 'should pass rack/lint' do
88107 env = Rack ::MockRequest . env_for ( "/test" )
89108
You can’t perform that action at this time.
0 commit comments