Aias00 opened a new issue, #6510: URL: https://github.com/apache/shenyu/issues/6510
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/shenyu/issues) and found no similar issues. ### Apache ShenYu Component shenyu-plugin ### What happened `ModifyResponseRuleHandle.replaceHeaderKeys` is documented as a header-name replacement map: ```java /** * replace header map * key: oldHeaderKey, value: newHeaderKey. */ private Map<String, String> replaceHeaderKeys; ``` But `ModifyResponsePlugin` applies the map like this: ```java if (MapUtils.isNotEmpty(this.ruleHandle.getReplaceHeaderKeys())) { Map<String, String> replaceHeaderMap = this.ruleHandle.getReplaceHeaderKeys(); replaceHeaderMap.forEach((key, value) -> httpHeaders.replace(key, Collections.singletonList(value))); } ``` `HttpHeaders.replace(key, values)` keeps the same header key and replaces its values. Therefore a rule such as: ```json { "replaceHeaderKeys": { "X-Old": "X-New" } } ``` will return: ```text X-Old: X-New ``` instead of renaming the header to: ```text X-New: <original X-Old values> ``` ### Expected behavior `replaceHeaderKeys` should rename response header keys according to the documented `oldHeaderKey -> newHeaderKey` mapping while preserving the original header values, or the field should be renamed/re-documented if the intended behavior is value replacement. The current implementation does neither and produces incorrect response headers. ### How to reproduce 1. Enable the modify-response plugin. 2. Configure a rule with `replaceHeaderKeys` mapping `X-Old` to `X-New`. 3. Let the upstream return `X-Old: abc`. 4. The gateway returns `X-Old: X-New` instead of `X-New: abc`. ### Debug logs _No response_ ### Environment Current `master` branch. ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
