Class HttpComponentsClientHttpConnector
java.lang.Object
org.springframework.http.client.reactive.HttpComponentsClientHttpConnector
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ClientHttpConnector
public class HttpComponentsClientHttpConnector
extends Object
implements ClientHttpConnector, Closeable
ClientHttpConnector
implementation for the Apache HttpComponents HttpClient 5.x.- Since:
- 5.3
- Author:
- Martin Tarjányi, Arjen Poutsma
- See Also:
-
Constructor Summary
ConstructorDescriptionDefault constructor that creates and starts a new instance ofCloseableHttpAsyncClient
.Constructor with a pre-configuredCloseableHttpAsyncClient
instance.HttpComponentsClientHttpConnector
(CloseableHttpAsyncClient client, BiFunction<HttpMethod, URI, ? extends HttpClientContext> contextProvider) Constructor with a pre-configuredCloseableHttpAsyncClient
instance and aHttpClientContext
supplier lambda which is called before each request and passed to the client. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
reactor.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 givenHttpMethod
andURI
and apply the givenrequestCallback
when the HTTP request of the underlying API can be initialized and written to.void
setBufferFactory
(DataBufferFactory bufferFactory) Set the buffer factory to use.
-
Constructor Details
-
HttpComponentsClientHttpConnector
public HttpComponentsClientHttpConnector()Default constructor that creates and starts a new instance ofCloseableHttpAsyncClient
. -
HttpComponentsClientHttpConnector
Constructor with a pre-configuredCloseableHttpAsyncClient
instance.- Parameters:
client
- the client to use
-
HttpComponentsClientHttpConnector
public HttpComponentsClientHttpConnector(CloseableHttpAsyncClient client, BiFunction<HttpMethod, URI, ? extends HttpClientContext> contextProvider) Constructor with a pre-configuredCloseableHttpAsyncClient
instance and aHttpClientContext
supplier lambda which is called before each request and passed to the client.- Parameters:
client
- the client to usecontextProvider
- aHttpClientContext
supplier
-
-
Method Details
-
setBufferFactory
Set the buffer factory to use. -
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:ClientHttpConnector
Connect to the origin server using the givenHttpMethod
andURI
and apply the givenrequestCallback
when the HTTP request of the underlying API can be initialized and written to.- Specified by:
connect
in 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(org.reactivestreams.Publisher<? extends org.springframework.core.io.buffer.DataBuffer>)
orReactiveHttpOutputMessage.setComplete()
.- Returns:
- publisher for the
ClientHttpResponse
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-