Server transports: remove deprecated methods from builder
Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
This commit is contained in:
parent
301dbe46ce
commit
8c7774ad5f
3 changed files with 0 additions and 96 deletions
|
|
@ -240,24 +240,6 @@ public class HttpClientSseClientTransport implements McpClientTransport {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies the given consumer to the shared {@link HttpRequest.Builder} <b>once,
|
|
||||||
* at build time</b>. Any headers set here are frozen into the template and
|
|
||||||
* <b>cannot be updated</b> after the transport is built.
|
|
||||||
* @param requestCustomizer the consumer to customize the HTTP request builder
|
|
||||||
* @return this builder
|
|
||||||
* @deprecated Use {@link #requestBuilder(HttpRequest.Builder)} for stable
|
|
||||||
* headers, or {@link #httpRequestCustomizer(McpSyncHttpClientRequestCustomizer)}
|
|
||||||
* / {@link #asyncHttpRequestCustomizer(McpAsyncHttpClientRequestCustomizer)} for
|
|
||||||
* dynamic per-request customization.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public Builder customizeRequest(final Consumer<HttpRequest.Builder> requestCustomizer) {
|
|
||||||
Assert.notNull(requestCustomizer, "requestCustomizer must not be null");
|
|
||||||
requestCustomizer.accept(requestBuilder);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the JSON mapper implementation to use for serialization/deserialization.
|
* Sets the JSON mapper implementation to use for serialization/deserialization.
|
||||||
* @param jsonMapper the JSON mapper
|
* @param jsonMapper the JSON mapper
|
||||||
|
|
|
||||||
|
|
@ -737,24 +737,6 @@ public class HttpClientStreamableHttpTransport implements McpClientTransport {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies the given consumer to the shared {@link HttpRequest.Builder} <b>once,
|
|
||||||
* at build time</b>. Any headers set here are frozen into the template and
|
|
||||||
* <b>cannot be updated</b> after the transport is built.
|
|
||||||
* @param requestCustomizer the consumer to customize the HTTP request builder
|
|
||||||
* @return this builder
|
|
||||||
* @deprecated Use {@link #requestBuilder(HttpRequest.Builder)} for stable
|
|
||||||
* headers, or {@link #httpRequestCustomizer(McpSyncHttpClientRequestCustomizer)}
|
|
||||||
* / {@link #asyncHttpRequestCustomizer(McpAsyncHttpClientRequestCustomizer)} for
|
|
||||||
* dynamic per-request customization.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public Builder customizeRequest(final Consumer<HttpRequest.Builder> requestCustomizer) {
|
|
||||||
Assert.notNull(requestCustomizer, "requestCustomizer must not be null");
|
|
||||||
requestCustomizer.accept(requestBuilder);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure a custom {@link McpJsonMapper} implementation to use.
|
* Configure a custom {@link McpJsonMapper} implementation to use.
|
||||||
* @param jsonMapper instance to use
|
* @param jsonMapper instance to use
|
||||||
|
|
|
||||||
|
|
@ -333,66 +333,6 @@ class HttpClientSseClientTransportTests {
|
||||||
customizedTransport.closeGracefully().block();
|
customizedTransport.closeGracefully().block();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testCustomizeRequest() {
|
|
||||||
// Create an atomic boolean to verify the customizer was called
|
|
||||||
AtomicBoolean customizerCalled = new AtomicBoolean(false);
|
|
||||||
|
|
||||||
// Create a reference to store the custom header value
|
|
||||||
AtomicReference<String> headerName = new AtomicReference<>();
|
|
||||||
AtomicReference<String> headerValue = new AtomicReference<>();
|
|
||||||
|
|
||||||
// Create a transport with the customizer
|
|
||||||
HttpClientSseClientTransport customizedTransport = HttpClientSseClientTransport.builder(host)
|
|
||||||
// Create a request customizer that adds a custom header
|
|
||||||
.customizeRequest(builder -> {
|
|
||||||
builder.header("X-Custom-Header", "test-value");
|
|
||||||
customizerCalled.set(true);
|
|
||||||
|
|
||||||
// Create a new request to verify the header was set
|
|
||||||
HttpRequest request = builder.uri(URI.create("http://example.com")).build();
|
|
||||||
headerName.set("X-Custom-Header");
|
|
||||||
headerValue.set(request.headers().firstValue("X-Custom-Header").orElse(null));
|
|
||||||
})
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Verify the customizer was called
|
|
||||||
assertThat(customizerCalled.get()).isTrue();
|
|
||||||
|
|
||||||
// Verify the header was set correctly
|
|
||||||
assertThat(headerName.get()).isEqualTo("X-Custom-Header");
|
|
||||||
assertThat(headerValue.get()).isEqualTo("test-value");
|
|
||||||
|
|
||||||
// Clean up
|
|
||||||
customizedTransport.closeGracefully().block();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testChainedCustomizations() {
|
|
||||||
// Create atomic booleans to verify both customizers were called
|
|
||||||
AtomicBoolean clientCustomizerCalled = new AtomicBoolean(false);
|
|
||||||
AtomicBoolean requestCustomizerCalled = new AtomicBoolean(false);
|
|
||||||
|
|
||||||
// Create a transport with both customizers chained
|
|
||||||
HttpClientSseClientTransport customizedTransport = HttpClientSseClientTransport.builder(host)
|
|
||||||
.customizeClient(builder -> {
|
|
||||||
builder.connectTimeout(Duration.ofSeconds(30));
|
|
||||||
clientCustomizerCalled.set(true);
|
|
||||||
})
|
|
||||||
.customizeRequest(builder -> {
|
|
||||||
builder.header("X-Api-Key", "test-api-key");
|
|
||||||
requestCustomizerCalled.set(true);
|
|
||||||
})
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Verify both customizers were called
|
|
||||||
assertThat(clientCustomizerCalled.get()).isTrue();
|
|
||||||
assertThat(requestCustomizerCalled.get()).isTrue();
|
|
||||||
|
|
||||||
// Clean up
|
|
||||||
customizedTransport.closeGracefully().block();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testRequestCustomizer() {
|
void testRequestCustomizer() {
|
||||||
var mockCustomizer = mock(McpSyncHttpClientRequestCustomizer.class);
|
var mockCustomizer = mock(McpSyncHttpClientRequestCustomizer.class);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue