fix: copy request builder to prevent side effects in HTTP transports (#333)
- Add .copy() call before modifying requestBuilder in FlowSseClient - Add .copy() call before modifying requestBuilder in HttpClientSseClientTransport - Prevents unintended mutations of shared builder instances
This commit is contained in:
parent
d4a1bfa58f
commit
fce7a6bad3
2 changed files with 4 additions and 2 deletions
|
|
@ -121,7 +121,8 @@ public class FlowSseClient {
|
|||
* @throws RuntimeException if the connection fails with a non-200 status code
|
||||
*/
|
||||
public void subscribe(String url, SseEventHandler eventHandler) {
|
||||
HttpRequest request = this.requestBuilder.uri(URI.create(url))
|
||||
HttpRequest request = this.requestBuilder.copy()
|
||||
.uri(URI.create(url))
|
||||
.header("Accept", "text/event-stream")
|
||||
.header("Cache-Control", "no-cache")
|
||||
.GET()
|
||||
|
|
|
|||
|
|
@ -415,7 +415,8 @@ public class HttpClientSseClientTransport implements McpClientTransport {
|
|||
try {
|
||||
String jsonText = this.objectMapper.writeValueAsString(message);
|
||||
URI requestUri = Utils.resolveUri(baseUri, endpoint);
|
||||
HttpRequest request = this.requestBuilder.uri(requestUri)
|
||||
HttpRequest request = this.requestBuilder.copy()
|
||||
.uri(requestUri)
|
||||
.POST(HttpRequest.BodyPublishers.ofString(jsonText))
|
||||
.build();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue