Skip to content

Commit 6561d16

Browse files
committed
replace path matching from getPathInfo to getRequestURI.
`getRequestURI()` → full request path (without query). `getPathInfo()` → extra path after the servlet's mapping, or null if none. So if I am configuring my Servlet to be mapped on `/somePath` and initiating the Servlet: ``` new HttpServletSseServerTransport(new ObjectMapper(), "/somePath/message", "/somePath/sse") ``` it will work and won't fail. `getPathInfo` will return "/message" and "/sse". while `getRequestURI` will return "/somePath/message" and "/somePath/sse" and will not fail on the validation.
1 parent a94163b commit 6561d16

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mcp/src/main/java/io/modelcontextprotocol/server/transport/HttpServletSseServerTransportProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ public Mono<Void> notifyClients(String method, Map<String, Object> params) {
170170
protected void doGet(HttpServletRequest request, HttpServletResponse response)
171171
throws ServletException, IOException {
172172

173-
String pathInfo = request.getPathInfo();
174-
if (!sseEndpoint.equals(pathInfo)) {
173+
String requestURI = request.getRequestURI();
174+
if (!sseEndpoint.equals(requestURI)) {
175175
response.sendError(HttpServletResponse.SC_NOT_FOUND);
176176
return;
177177
}
@@ -225,8 +225,8 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
225225
return;
226226
}
227227

228-
String pathInfo = request.getPathInfo();
229-
if (!messageEndpoint.equals(pathInfo)) {
228+
String requestURI = request.getRequestURI();
229+
if (!messageEndpoint.equals(requestURI)) {
230230
response.sendError(HttpServletResponse.SC_NOT_FOUND);
231231
return;
232232
}

0 commit comments

Comments
 (0)