Repository navigation
Conversation
…ttpClientPlugin For every proxied response, NettyHttpClientPlugin built an intermediate Spring HttpHeaders (a LinkedCaseInsensitiveMap with a list per name) from the upstream Netty headers and wrote it through Spring's adapter back into the Reactor Netty response headers. Since Spring 6.1, the server response's getHeaders() is a live view of the Netty headers, so the intermediate map is unnecessary in the default case. The plugin now takes a fast path when the response is Spring's own package-private ReactorServerHttpResponse (matched by class name), not yet committed, no RESP_UNIQUE_HEADER handling is configured (the dedup works on the intermediate map) and the plugin is not subclassed (identity comparison — subclasses may override doRequest): it sets each upstream name directly on the native Netty headers, which the live view exposes unchanged. In every other case the existing path is unchanged, including the UnsupportedOperationException guard for read-only responses behind decorators.
…t path set(name, value) per upstream entry made duplicate names last-wins, dropping values for headers that legitimately repeat (Set-Cookie). The fast path now follows the issue wording exactly: remove the names the upstream sends, then add every upstream entry — multi-value headers keep all their values, the same putAll semantics as the slow path. A test pins a two-value Set-Cookie.
wy471x
left a comment
There was a problem hiding this comment.
Review: request changes (one correctness gap, otherwise clean)
Thanks — the allocation-only framing, the four guards and the byte-identical fallback are all in good shape. There is one blocking issue.
Blocking: the native header copy bypasses HttpRouteResponseHeaders.apply
copyUpstreamHeadersFast(...) runs at the top of the response callback, i.e. before HttpRouteResponseHeaders.apply(exchange, () -> ...). That wrapper is not just a status guard: it snapshots the gateway's uncommitted headers before the first upstream write, and when a timed route has already been restored it suppresses all late upstream writes (state.timedOut). With this patch:
- If the route already timed out, the upstream headers still land on the native Netty headers while the wrapper only suppresses the status write — a timeout response can advertise the upstream's
content-type,set-cookieorcontent-length. - The snapshot taken inside
applynow already contains the upstream headers, sorestore()restores a contaminated header set. The PR description ("the wrapper's snapshot reads the fast path's writes through the live view") describes the opposite order of what the code does.
Fix: move the native write inside the runnable passed to apply, so both paths share the same seam and the timed-out suppression applies to the fast path too. Please add a regression test that installs the HttpRouteResponseHeaders state, makes it time out, and asserts that no upstream header reaches the native headers.
Non-blocking
final HttpHeaders headers = nativeCopy ? null : slowPathHeaders(...)introduces a null-typed flow through a method call; two explicit branches read better and remove the null.copyUpstreamHeadersFastis package-private only so the test can call it, and the tests never exercisedoRequest. Prefer keeping it private and asserting throughdoRequestwith a realReactorServerHttpResponse(like #8436's socket-based tests do).- The committed-response test reflects into
AbstractServerHttpResponse.stateand the package-privateState.valueOf; that breaks silently on Spring upgrades. Guard it with an assumption so it skips instead of erroring. - The description says the fast path uses "
set= replace values per name"; the code does remove+add. The semantics are equivalent, but please align the wording.
Duplicate PR
#8436 targets the same issue #8435. Please consolidate on one PR. This one is the better shape (it keeps the apply seam and is a smaller divergence) — after the fix above I'd support merging this PR and closing #8436.
Note: the class-name match and the getClass() != NettyHttpClientPlugin.class guard are exactly what the issue prescribes, so I'm not asking you to change that design.
Closing in favor of the original author's PR (#8436) — apologies for the duplicate: my claim checklist missed the linked PRs, which the issue search surface does not show. The work here added nothing beyond what that PR already covers.