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
…vention, and concurrent calls
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
|
| final List<Future<Void>> futures = executor.invokeAll(tasks); | ||
| for (final Future<Void> future : futures) { | ||
| future.get(); | ||
| } | ||
| executor.shutdown(); |


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.