Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain any literal "HTTP-" in header names #950

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/raven/integrations/rack.rb
Expand Up @@ -113,7 +113,7 @@ def format_headers_for_sentry(env_hash)

next unless key.start_with?('HTTP_') || %w(CONTENT_TYPE CONTENT_LENGTH).include?(key)
# Rack stores headers as HTTP_WHAT_EVER, we need What-Ever
key = key.gsub("HTTP_", "")
key = key.sub(/^HTTP_/, "")
key = key.split('_').map(&:capitalize).join('-')
memo[key] = value
rescue StandardError => e
Expand Down
8 changes: 8 additions & 0 deletions spec/raven/integrations/rack_spec.rb
Expand Up @@ -103,6 +103,14 @@
expect(interface.headers["Version"]).to eq("HTTP/2.0")
end

it 'retains any literal "HTTP-" in the actual header name' do
interface = Raven::HttpInterface.new
new_env = env.merge("HTTP_HTTP_CUSTOM_HTTP_HEADER" => "test")
interface.from_rack(new_env)

expect(interface.headers).to include("Http-Custom-Http-Header" => "test")
end

it 'does not fail if an object in the env cannot be cast to string' do
obj = Class.new do
def to_s
Expand Down