Support o.s.h.HttpHeaders from both 6.x and 7.x branches to enable migration to Spring 7 (#639)

This commit is contained in:
Dmitry Bedrin 2025-10-30 16:27:08 +01:00 • committed by GitHub
commit 14ff4a385d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -240,7 +240,7 @@ public class WebMvcStreamableServerTransportProvider implements McpStreamableSer
McpTransportContext transportContext = this.contextExtractor.extract(request);
if (!request.headers().asHttpHeaders().containsKey(HttpHeaders.MCP_SESSION_ID)) {
if (request.headers().header(HttpHeaders.MCP_SESSION_ID).isEmpty()) {
return ServerResponse.badRequest().body("Session ID required in mcp-session-id header");
}
@ -263,7 +263,7 @@ public class WebMvcStreamableServerTransportProvider implements McpStreamableSer
sessionId, sseBuilder);
// Check if this is a replay request
if (request.headers().asHttpHeaders().containsKey(HttpHeaders.LAST_EVENT_ID)) {
if (!request.headers().header(HttpHeaders.LAST_EVENT_ID).isEmpty()) {
String lastId = request.headers().asHttpHeaders().getFirst(HttpHeaders.LAST_EVENT_ID);
try {
@ -354,7 +354,7 @@ public class WebMvcStreamableServerTransportProvider implements McpStreamableSer
}
// Handle other messages that require a session
if (!request.headers().asHttpHeaders().containsKey(HttpHeaders.MCP_SESSION_ID)) {
if (request.headers().header(HttpHeaders.MCP_SESSION_ID).isEmpty()) {
return ServerResponse.badRequest().body(new McpError("Session ID missing"));
}
@ -433,7 +433,7 @@ public class WebMvcStreamableServerTransportProvider implements McpStreamableSer
McpTransportContext transportContext = this.contextExtractor.extract(request);
if (!request.headers().asHttpHeaders().containsKey(HttpHeaders.MCP_SESSION_ID)) {
if (request.headers().header(HttpHeaders.MCP_SESSION_ID).isEmpty()) {
return ServerResponse.badRequest().body("Session ID required in mcp-session-id header");
}