Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions disclosure.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This change was submitted despite me reading the rules and understanding AI contribution guidelines.
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
.listeningStream(sessionTransport);

registerAsyncLifecycle(asyncContext, sessionId, listeningStream::releaseTransport);
response.flushBuffer();
}
catch (Exception e) {
logger.error("Failed to handle GET request for session {}: {}", sessionId, e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Queue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Stream;
Expand Down Expand Up @@ -450,6 +451,26 @@ void sessionIsNotEvictedWithoutSweepInterval() {
}
}

@Test
void getStreamSendsHeadersBeforeFirstEvent() throws Exception {
withTransportProvider(null, null);
String sessionId = initializeSession(httpClient);

var get = HttpRequest.newBuilder()
.uri(URI.create("http://localhost:" + PORT + MESSAGE_ENDPOINT))
.header("Accept", "text/event-stream")
.header(HttpHeaders.MCP_SESSION_ID, sessionId)
.GET()
.build();

HttpResponse<InputStream> response = httpClient.sendAsync(get, HttpResponse.BodyHandlers.ofInputStream())
.get(5, TimeUnit.SECONDS);

assertThat(response.statusCode()).isEqualTo(HttpServletResponse.SC_OK);
assertThat(response.headers().firstValue("Content-Type").orElse("")).startsWith("text/event-stream");
response.body().close();
}

/**
* A client which aborts a tool call must not leave its session behind.
*/
Expand Down