spring-cloud / spring-cloud/spring-cloud-gateway
Modify entries in an event-stream response
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.9k
- Forks
- 3.5k
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 8
Description
Using modifyResponseBody() in Gateway MVC as an after filter works great generally speaking. But if the response is a "text/event-stream", it blocks awaiting the entire body response (which will never come) and the RewriteResponseFunction is never invoked.
This is important because if any of the entries in the event stream carry a path back to the target server, that path is relative to the target server, not the gateway. For example, if proxying an HTTP+SSE server through the gateway, the first request is a GET request to /sse. The response will carry something like this:
data: /message?sessionId=15db30b7-2cfb-4550-a015-c9a2ae7617e0
The MCP client will use that path to send POST requests for all future interactions with the MCP Server. But again, that path is relative to the target MCP Server, not the gateway. Therefore, the client gets an HTTP 404.
What needs to happen is to be able to rewrite that path to a gateway-relative path (e.g., "/mymcpserver/message?sessionId=...")
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Gateway MVC's modifyResponseBody() after filter and trace how RewriteResponseFunction is invoked for text/event-stream responses. Determine how an event-stream entry such as the session path can be rewritten to a gateway-relative path without waiting for the complete response; done means the MCP client can use the rewritten path for subsequent POST requests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100