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:
parent
0980f08e94
commit
14ff4a385d
2 changed files with 8 additions and 8 deletions
|
|
@ -174,7 +174,7 @@ public class WebFluxStreamableServerTransportProvider implements McpStreamableSe
|
|||
return ServerResponse.badRequest().build();
|
||||
}
|
||||
|
||||
if (!request.headers().asHttpHeaders().containsKey(HttpHeaders.MCP_SESSION_ID)) {
|
||||
if (request.headers().header(HttpHeaders.MCP_SESSION_ID).isEmpty()) {
|
||||
return ServerResponse.badRequest().build(); // TODO: say we need a session
|
||||
// id
|
||||
}
|
||||
|
|
@ -187,7 +187,7 @@ public class WebFluxStreamableServerTransportProvider implements McpStreamableSe
|
|||
return ServerResponse.notFound().build();
|
||||
}
|
||||
|
||||
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);
|
||||
return ServerResponse.ok()
|
||||
.contentType(MediaType.TEXT_EVENT_STREAM)
|
||||
|
|
@ -258,7 +258,7 @@ public class WebFluxStreamableServerTransportProvider implements McpStreamableSe
|
|||
.bodyValue(initResult));
|
||||
}
|
||||
|
||||
if (!request.headers().asHttpHeaders().containsKey(HttpHeaders.MCP_SESSION_ID)) {
|
||||
if (request.headers().header(HttpHeaders.MCP_SESSION_ID).isEmpty()) {
|
||||
return ServerResponse.badRequest().bodyValue(new McpError("Session ID missing"));
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +313,7 @@ public class WebFluxStreamableServerTransportProvider implements McpStreamableSe
|
|||
McpTransportContext transportContext = this.contextExtractor.extract(request);
|
||||
|
||||
return Mono.defer(() -> {
|
||||
if (!request.headers().asHttpHeaders().containsKey(HttpHeaders.MCP_SESSION_ID)) {
|
||||
if (request.headers().header(HttpHeaders.MCP_SESSION_ID).isEmpty()) {
|
||||
return ServerResponse.badRequest().build(); // TODO: say we need a session
|
||||
// id
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue