Class JdkClientHttpConnector
java.lang.Object
org.springframework.http.client.reactive.JdkClientHttpConnector
- All Implemented Interfaces:
ClientHttpConnector
ClientHttpConnector for the Java HttpClient.- Since:
- 6.0
- Author:
- Julien Eyraud, Rossen Stoyanchev
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor that usesHttpClient.newHttpClient().JdkClientHttpConnector(HttpClient httpClient) Constructor with an initializedHttpClientand aDataBufferFactory.JdkClientHttpConnector(HttpClient.Builder clientBuilder, @Nullable JdkHttpClientResourceFactory resourceFactory) Constructor with aJdkHttpClientResourceFactorythat provides shared resources. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<ClientHttpResponse> connect(HttpMethod method, URI uri, Function<? super ClientHttpRequest, reactor.core.publisher.Mono<Void>> requestCallback) Connect to the origin server using the givenHttpMethodandURIand apply the givenrequestCallbackwhen the HTTP request of the underlying API can be initialized and written to.voidsetBufferFactory(DataBufferFactory bufferFactory) Set the buffer factory to use.voidsetCookieParser(ResponseCookie.Parser parser) Customize the parsing of response cookies.voidsetReadTimeout(Duration readTimeout) Set the underlyingHttpClientread timeout as aDuration.
-
Constructor Details
-
JdkClientHttpConnector
public JdkClientHttpConnector()Default constructor that usesHttpClient.newHttpClient(). -
JdkClientHttpConnector
Constructor with an initializedHttpClientand aDataBufferFactory. -
JdkClientHttpConnector
public JdkClientHttpConnector(HttpClient.Builder clientBuilder, @Nullable JdkHttpClientResourceFactory resourceFactory) Constructor with aJdkHttpClientResourceFactorythat provides shared resources.- Parameters:
clientBuilder- a pre-initialized builder for the client that will be further initialized with the shared resources to useresourceFactory- theJdkHttpClientResourceFactoryto use
-
-
Method Details
-
setBufferFactory
Set the buffer factory to use.By default, this is
DefaultDataBufferFactory.sharedInstance. -
setReadTimeout
Set the underlyingHttpClientread timeout as aDuration.Default is the system's default timeout.
- Since:
- 6.2
- See Also:
-
setCookieParser
Customize the parsing of response cookies.By default,
HttpCookie.parse(String)is used, and additionally the sameSite attribute is parsed and set.- Parameters:
parser- the parser to use- Since:
- 7.0
-
connect
public reactor.core.publisher.Mono<ClientHttpResponse> connect(HttpMethod method, URI uri, Function<? super ClientHttpRequest, reactor.core.publisher.Mono<Void>> requestCallback) Description copied from interface:ClientHttpConnectorConnect to the origin server using the givenHttpMethodandURIand apply the givenrequestCallbackwhen the HTTP request of the underlying API can be initialized and written to.- Specified by:
connectin interfaceClientHttpConnector- Parameters:
method- the HTTP request methoduri- the HTTP request URIrequestCallback- a function that prepares and writes to the request, returning a publisher that signals when it's done writing. Implementations can return aMono<Void>by callingReactiveHttpOutputMessage.writeWith(Publisher)orReactiveHttpOutputMessage.setComplete().- Returns:
- publisher for the
ClientHttpResponse
-