Add real-IO SSE server transport handshake test#216
Merged
Conversation
added 2 commits
April 20, 2026 08:50
Exercises the GET /sse -> 200 + event:endpoint handshake end-to-end
through a socketpair-backed ConnectionImpl and the real
HttpSseFilterChainFactory, without standing up a full McpServer. Covers:
- default handshake advertises a callback URL with a non-empty
session id and Content-Type: text/event-stream;
- external_url is honored in the advertised endpoint (the internal
Host header is not leaked through);
- a configured sse_path is honored for the GET endpoint.
The POST /callback/{id} -> 202 -> response-through-stream leg is
documented as deferred in the test header; it requires either a full
McpServer bootstrap or a test-only connection-tracking filter to capture
the Connection* from onRequest, and is tracked as a follow-up.
Teardown tears the connection and the factory down on the dispatcher
thread to satisfy ConnectionImpl and SseSessionRegistry thread-affinity
asserts.
Extends the SSE transport round-trip test with the second leg that PR separate server connection returns 202 Accepted, and a JSON-RPC response produced on that POST connection is rerouted by HttpSseJsonRpcProtocolFilter::onWrite through SseSessionRegistry onto the original SSE stream — not framed back as HTTP bytes on the POST socket. The test runs two ServerConnections over separate socketpairs against a single shared HttpSseFilterChainFactory, which is the key to exercising the cross-connection routing: both filter instances share the factory's SseSessionRegistry, so the POST-side filter can find and write to the SSE-side connection. No McpServer bootstrap is needed. A test-only McpProtocolCallbacks emits the response via connection().write() from onRequest — the same write chain the real McpServer's JSON-RPC encoder would drive — so the onWrite interception runs against real JSON-RPC bytes rather than a mocked payload. Header comment updated to reflect that both legs are now covered.
7d4020b to
81460bf
Compare
caleb2h
approved these changes
Apr 20, 2026
gophergogo
pushed a commit
that referenced
this pull request
Apr 20, 2026
Exercises the GET /sse -> 200 + event:endpoint handshake end-to-end
through a socketpair-backed ConnectionImpl and the real
HttpSseFilterChainFactory, without standing up a full McpServer. Covers:
- default handshake advertises a callback URL with a non-empty
session id and Content-Type: text/event-stream;
- external_url is honored in the advertised endpoint (the internal
Host header is not leaked through);
- a configured sse_path is honored for the GET endpoint.
The POST /callback/{id} -> 202 -> response-through-stream leg is
documented as deferred in the test header; it requires either a full
McpServer bootstrap or a test-only connection-tracking filter to capture
the Connection* from onRequest, and is tracked as a follow-up.
Teardown tears the connection and the factory down on the dispatcher
thread to satisfy ConnectionImpl and SseSessionRegistry thread-affinity
asserts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
event: endpointhandshake end-to-end through a socketpair-backedConnectionImpland the realHttpSseFilterChainFactory, without standing up a fullMcpServer.Content-Type: text/event-stream;external_urlis honored in the advertised endpoint (the internalHostheader is not leaked through);sse_pathis honored for the GET endpoint.ConnectionImplandSseSessionRegistrythread-affinity asserts hold.The POST
/callback/{id}→ 202 → response-through-stream leg of the round-trip is documented as deferred in the test header; it requires either a fullMcpServerbootstrap or a test-only connection-tracking filter to capture theConnection*fromonRequest, and is tracked as a follow-up.Test plan
ctest -R SseTransportRoundTripTestpassesctestsuite passes (121/121)