[BUG] WebClient response-header deduplication is overwritten by WebClientMessageWriter
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
## Description
`WebClientPlugin.doRequest` deduplicates the upstream response headers and puts them on `exchange.getResponse().getHeaders()`. But later, `WebClientMessageWriter.redrawResponseHeaders` reads the **original** non-deduplicated upstream headers straight from `fluxResponseEntity.getHeaders()` and does `response.getHeaders().putAll(httpHeaders)`. Since `HttpHeaders.putAll` *replaces* each key's value list, the deduped values written by `WebClientPlugin` are overwritten with the full multi-valued upstream headers. The Netty path does not have this regression.
## Location
```
shenyu-plugin-httpclient/.../WebClientPlugin.java:97-100
shenyu-plugin-response/.../WebClientMessageWriter.java:106,121
```
## Impact
Downstream clients receive duplicate response headers despite the retain-first/last/unique configuration; behavior diverges between WebClient and Netty client backends.
## Suggested fix
Perform the response-header dedup inside `redrawResponseHeaders` (on the copy before `putAll`), or have `redrawResponseHeaders` reuse the response headers already set by `WebClientPlugin`.
## Related existing issue(s)
None
_Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading WebClientPlugin.doRequest around lines 97-100 and WebClientMessageWriter.redrawResponseHeaders around lines 106 and 121. Trace how the response headers flow into putAll, then verify that the configured retain-first, retain-last, or unique behavior remains effective and matches the Netty path without duplicate downstream headers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100