Repository navigation
fix(http): support multi-valued headers and request isolation in HeadersInspectionHandler - #2214
Conversation
|
Hi Vincent Biret (@baywet)! This PR fixes multi-valued header handling in |
…and prevent stale response headers
fde7d9f to
d4bd310
Compare
|
Hi Vincent Biret (@baywet) and @andreastman, I've addressed all Copilot review feedback and resolved the formatting and lint checks. Here's a summary of the changes: 1. Synchronize Shared Header Capture
2. Clear Response Headers Before
|
…vention, and concurrent calls
d4bd310 to
a66dfe5
Compare
|
PR has been updated and all checks are passing:
Ready for review and merge! |
…pping response mixing
|
I have updated the PR to address the overlapping response mixing finding:
Thank you! |
Vincent Biret (baywet)
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
I'll disregard my earlier comment. Although it's technically extremely unlikely to get a mixup for response headers, it is theoretically possible.


Summary
In
HeadersInspectionHandler, there were three issues in header inspection and telemetry:HeadersInspectionHandlerpreviously created anew HashSet<String>()per header and calledput(header.getFirst(), value)onRequestHeadersandResponseHeaders. When multiple entries existed for the same header name (e.g.,Set-Cookie,Accept,Vary), subsequent values replaced the set instead of accumulating, leaving only the last value. By delegating toadd(key, value), all values for the header are preserved.HeadersInspectionOptioninstance was reused across requests, headers from previous requests were never cleared and leaked into subsequent requests.com.microsoft.kiota.handler.headersInspection.enablewas hardcoded totrueeven when inspection was disabled; it now reflectsinspectionOption.getInspectRequestHeaders() || inspectionOption.getInspectResponseHeaders().Changes
.put(header.getFirst(), value)with.add(header.getFirst(), header.getSecond())inHeadersInspectionHandler.java..clear()calls togetRequestHeaders()andgetResponseHeaders()prior to recording headers for each request/response.HeadersInspectionHandlerTest.javaverifying preservation of multi-valued headers and header isolation across requests.