yangjj-iso opened a new pull request, #7658:
URL: https://github.com/apache/shenyu/pull/7658

   Fixes #5594.
   
   `WebFluxResultUtils.result()` always replaces the response Content-Type with 
text/plain, the ShenyuResult default, or the upstream response type. This 
discards a type explicitly set by a plugin. In particular, a ModifyResponse 
rule that changes both headers and the JSON body loses its configured 
Content-Type when it writes the modified bytes.
   
   Only infer a Content-Type when the response has none. Existing headers, 
including their charset, now take precedence. With no header, the existing 
basic-value, upstream-response, and custom ShenyuResult defaults continue to 
apply. Result formatting, serialization, and content-length calculation still 
run normally.
   
   Add 15 API scenarios covering explicit headers, basic values, bytes, 
structured values, both Netty and WebClient upstream response forms, custom 
result formatting/defaults, and null results. Add a ModifyResponse regression 
that changes a body key and Content-Type while an upstream JSON response and an 
old Content-Length are present. Use the real default result implementation in 
the existing non-JSON-header body test and assert that its header is retained.
   
   Validation:
   - Original code: 7 of the 15 new API scenarios fail; the ModifyResponse 
regression also fails because XML is overwritten with upstream JSON.
   - After the fix: all 52 selected tests pass with no failures/errors/skips, 
including all tests in the API, ModifyResponse, and response-writer modules 
plus the base result/decorator tests.
   - Checkstyle and Apache RAT pass across the affected reactor; `git diff 
--check` passes.
   - Full-repository install and deployed-gateway testing were not run locally.
   
   ```sh
   ./mvnw -B -ntp -pl 
shenyu-plugin/shenyu-plugin-modify-response,shenyu-plugin/shenyu-plugin-response
 -am test \
     
'-Dtest=WebFluxResultUtilsTest,ShenyuResultEnumTest,ShenyuResultWrapTest,ResponseDecoratorTest,ModifyResponse*Test,*MessageWriterTest,ResponsePluginTest,WebClientChainCleanupTest'
 \
     -Dsurefire.failIfNoSpecifiedTests=false -DskipRemoteResources=true \
     -Djacoco.skip=true -Dmaven.javadoc.skip=true
   ./mvnw -B -ntp -pl 
shenyu-plugin/shenyu-plugin-modify-response,shenyu-plugin/shenyu-plugin-response
 -am apache-rat:check -DskipRemoteResources=true
   ```
   
   - [x] Read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide/).
   - [x] Submit regression tests.
   - [ ] Full local `./mvnw clean install -Dmaven.javadoc.skip=true` 
(affected-reactor validation above).
   


-- 
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]

Reply via email to