Skip to content

fix: apply modify response rules to streaming responses - #6990

Open
liudawang001 wants to merge 1 commit into
apache:masterfrom
liudawang001:fix/6659-streaming-modify-response
Open

fix: apply modify response rules to streaming responses#6990
liudawang001 wants to merge 1 commit into
apache:masterfrom
liudawang001:fix/6659-streaming-modify-response

Conversation

@liudawang001

@liudawang001 liudawang001 commented Aug 27, 2026

Copy link
Copy Markdown

What happened?

ModifyResponseDecorator only overrides writeWith().

For streaming responses such as SSE and NDJSON, WebFlux invokes
writeAndFlushWith(), which previously bypassed
modifyResponseHeadersAndStatus(). As a result, configured response headers
and status codes were not applied.

What does this PR do?

Override writeAndFlushWith() in ModifyResponseDecorator and invoke
modifyResponseHeadersAndStatus() before delegating the original streaming
body.

The body is neither aggregated nor modified, so the original streaming and
flush behavior is preserved.

Tests

Added a regression test covering the writeAndFlushWith() path.

Verified that:

  • Without the fix, the regression test fails because the configured response
    header is not applied.
  • With the fix, the regression test passes.
  • All 8 tests in shenyu-plugin-modify-response pass.
  • Checkstyle reports no violations.
  • git diff --check passes.

Fixes #6659

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ModifyResponsePlugin silently skips all modifications for streaming responses (writeAndFlushWith not overridden)

1 participant