Skip to content

Commit

Permalink
Applied performance related suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
vpellan committed Jul 19, 2024
1 parent 86b882a commit fa699c8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/datadog/appsec/contrib/rack/gateway/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ def headers
# When multiple headers with the same name are present, they are concatenated with a comma
# https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
# Because headers are case insensitive, HTTP_FOO and HTTP_Foo is the same, and should be merged
if k =~ /^HTTP_/
key = k.gsub(/^HTTP_/, '').tap(&:downcase!).tap { |s| s.tr!('_', '-') }
h[key] = h[key].nil? ? v : "#{h[key]}, #{v}"
end
next unless k.start_with?('HTTP_')

key = k.delete_prefix('HTTP_').tap(&:downcase!).tap { |s| s.tr!('_', '-') }
current_val = h[key]
h[key] = current_val.nil? ? v : "#{current_val}, #{v}"
end

result['content-type'] = request.content_type if request.content_type
Expand Down

0 comments on commit fa699c8

Please sign in to comment.