@@ -170,8 +170,7 @@ public HttpClientSseClientTransport(HttpClient.Builder clientBuilder, String bas
170
170
@ Deprecated (forRemoval = true )
171
171
public HttpClientSseClientTransport (HttpClient .Builder clientBuilder , HttpRequest .Builder requestBuilder ,
172
172
String baseUri , String sseEndpoint , ObjectMapper objectMapper ) {
173
- this (clientBuilder .connectTimeout (Duration .ofSeconds (10 )).build (), requestBuilder , baseUri , sseEndpoint ,
174
- objectMapper );
173
+ this (clientBuilder .build (), requestBuilder , baseUri , sseEndpoint , objectMapper );
175
174
}
176
175
177
176
/**
@@ -241,9 +240,7 @@ public static class Builder {
241
240
242
241
private String sseEndpoint = DEFAULT_SSE_ENDPOINT ;
243
242
244
- private HttpClient .Builder clientBuilder = HttpClient .newBuilder ()
245
- .version (HttpClient .Version .HTTP_1_1 )
246
- .connectTimeout (Duration .ofSeconds (10 ));
243
+ private HttpClient .Builder clientBuilder = HttpClient .newBuilder ().version (HttpClient .Version .HTTP_1_1 );
247
244
248
245
private ObjectMapper objectMapper = new ObjectMapper ();
249
246
@@ -252,6 +249,8 @@ public static class Builder {
252
249
253
250
private AsyncHttpRequestCustomizer httpRequestCustomizer = AsyncHttpRequestCustomizer .NOOP ;
254
251
252
+ private Duration connectTimeout = Duration .ofSeconds (10 );
253
+
255
254
/**
256
255
* Creates a new builder instance.
257
256
*/
@@ -383,13 +382,25 @@ public Builder asyncHttpRequestCustomizer(AsyncHttpRequestCustomizer asyncHttpRe
383
382
return this ;
384
383
}
385
384
385
+ /**
386
+ * Sets the connection timeout for the HTTP client.
387
+ * @param connectTimeout the connection timeout duration
388
+ * @return this builder
389
+ */
390
+ public Builder connectTimeout (Duration connectTimeout ) {
391
+ Assert .notNull (connectTimeout , "connectTimeout must not be null" );
392
+ this .connectTimeout = connectTimeout ;
393
+ return this ;
394
+ }
395
+
386
396
/**
387
397
* Builds a new {@link HttpClientSseClientTransport} instance.
388
398
* @return a new transport instance
389
399
*/
390
400
public HttpClientSseClientTransport build () {
391
- return new HttpClientSseClientTransport (clientBuilder .build (), requestBuilder , baseUri , sseEndpoint ,
392
- objectMapper , httpRequestCustomizer );
401
+ HttpClient httpClient = this .clientBuilder .connectTimeout (this .connectTimeout ).build ();
402
+ return new HttpClientSseClientTransport (httpClient , requestBuilder , baseUri , sseEndpoint , objectMapper ,
403
+ httpRequestCustomizer );
393
404
}
394
405
395
406
}
0 commit comments