Fix httpRequestCustomizer usage in HttpClientStreamableHttpTransport
- Closes #458 Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
This commit is contained in:
parent
f7baf59acf
commit
c49f24f068
3 changed files with 4 additions and 4 deletions
|
|
@ -400,7 +400,7 @@ public class HttpClientStreamableHttpTransport implements McpClientTransport {
|
||||||
.header("Cache-Control", "no-cache")
|
.header("Cache-Control", "no-cache")
|
||||||
.header(HttpHeaders.PROTOCOL_VERSION, MCP_PROTOCOL_VERSION)
|
.header(HttpHeaders.PROTOCOL_VERSION, MCP_PROTOCOL_VERSION)
|
||||||
.POST(HttpRequest.BodyPublishers.ofString(jsonBody));
|
.POST(HttpRequest.BodyPublishers.ofString(jsonBody));
|
||||||
return Mono.from(this.httpRequestCustomizer.customize(builder, "GET", uri, jsonBody));
|
return Mono.from(this.httpRequestCustomizer.customize(builder, "POST", uri, jsonBody));
|
||||||
}).flatMapMany(requestBuilder -> Flux.<ResponseEvent>create(responseEventSink -> {
|
}).flatMapMany(requestBuilder -> Flux.<ResponseEvent>create(responseEventSink -> {
|
||||||
|
|
||||||
// Create the async request with proper body subscriber selection
|
// Create the async request with proper body subscriber selection
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ public class HttpClientStreamableHttpTransportEmptyJsonResponseTest {
|
||||||
StepVerifier.create(transport.sendMessage(testMessage)).verifyComplete();
|
StepVerifier.create(transport.sendMessage(testMessage)).verifyComplete();
|
||||||
|
|
||||||
// Verify the customizer was called
|
// Verify the customizer was called
|
||||||
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("GET"), eq(uri), eq(
|
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("POST"), eq(uri), eq(
|
||||||
"{\"jsonrpc\":\"2.0\",\"method\":\"initialize\",\"id\":\"test-id\",\"params\":{\"protocolVersion\":\"2025-03-26\",\"capabilities\":{\"roots\":{\"listChanged\":true}},\"clientInfo\":{\"name\":\"Spring AI MCP Client\",\"version\":\"0.3.1\"}}}"));
|
"{\"jsonrpc\":\"2.0\",\"method\":\"initialize\",\"id\":\"test-id\",\"params\":{\"protocolVersion\":\"2025-03-26\",\"capabilities\":{\"roots\":{\"listChanged\":true}},\"clientInfo\":{\"name\":\"Spring AI MCP Client\",\"version\":\"0.3.1\"}}}"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ class HttpClientStreamableHttpTransportTest {
|
||||||
StepVerifier.create(t.sendMessage(testMessage)).verifyComplete();
|
StepVerifier.create(t.sendMessage(testMessage)).verifyComplete();
|
||||||
|
|
||||||
// Verify the customizer was called
|
// Verify the customizer was called
|
||||||
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("GET"), eq(uri), eq(
|
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("POST"), eq(uri), eq(
|
||||||
"{\"jsonrpc\":\"2.0\",\"method\":\"initialize\",\"id\":\"test-id\",\"params\":{\"protocolVersion\":\"2025-03-26\",\"capabilities\":{\"roots\":{\"listChanged\":true}},\"clientInfo\":{\"name\":\"Spring AI MCP Client\",\"version\":\"0.3.1\"}}}"));
|
"{\"jsonrpc\":\"2.0\",\"method\":\"initialize\",\"id\":\"test-id\",\"params\":{\"protocolVersion\":\"2025-03-26\",\"capabilities\":{\"roots\":{\"listChanged\":true}},\"clientInfo\":{\"name\":\"Spring AI MCP Client\",\"version\":\"0.3.1\"}}}"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -107,7 +107,7 @@ class HttpClientStreamableHttpTransportTest {
|
||||||
StepVerifier.create(t.sendMessage(testMessage)).verifyComplete();
|
StepVerifier.create(t.sendMessage(testMessage)).verifyComplete();
|
||||||
|
|
||||||
// Verify the customizer was called
|
// Verify the customizer was called
|
||||||
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("GET"), eq(uri), eq(
|
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("POST"), eq(uri), eq(
|
||||||
"{\"jsonrpc\":\"2.0\",\"method\":\"initialize\",\"id\":\"test-id\",\"params\":{\"protocolVersion\":\"2025-03-26\",\"capabilities\":{\"roots\":{\"listChanged\":true}},\"clientInfo\":{\"name\":\"Spring AI MCP Client\",\"version\":\"0.3.1\"}}}"));
|
"{\"jsonrpc\":\"2.0\",\"method\":\"initialize\",\"id\":\"test-id\",\"params\":{\"protocolVersion\":\"2025-03-26\",\"capabilities\":{\"roots\":{\"listChanged\":true}},\"clientInfo\":{\"name\":\"Spring AI MCP Client\",\"version\":\"0.3.1\"}}}"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue