Skip to content

Commit 1281ebf

Browse files
authored
L-1147 Make sure filter_http_headers never modifies headers outside of logging (#17)
1 parent 909e7a2 commit 1281ebf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/logtail-rack/http_events.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,11 @@ def silenced?(env, request)
269269
end
270270

271271
def filter_http_headers(headers)
272-
headers.each do |name, _|
273-
normalized_header_name = self.class.normalize_header_name(name)
274-
headers[name] = "[FILTERED]" if self.class.http_header_filters&.include?(normalized_header_name)
275-
end
272+
headers.map do |name, value|
273+
normalized_name = self.class.normalize_header_name(name)
274+
is_filtered = self.class.http_header_filters&.include?(normalized_name)
275+
[name, is_filtered ? "[FILTERED]" : value]
276+
end.to_h
276277
end
277278

278279
def safe_to_i(val)

0 commit comments

Comments
 (0)