public class HttpComponentsClientHttpConnector extends Object implements ClientHttpConnector, Closeable
ClientHttpConnector
implementation for the Apache HttpComponents HttpClient 5.x.Constructor and Description |
---|
HttpComponentsClientHttpConnector()
Default constructor that creates and starts a new instance of
CloseableHttpAsyncClient . |
HttpComponentsClientHttpConnector(CloseableHttpAsyncClient client)
Constructor with a pre-configured
CloseableHttpAsyncClient instance. |
HttpComponentsClientHttpConnector(CloseableHttpAsyncClient client,
BiFunction<HttpMethod,URI,? extends HttpClientContext> contextProvider)
Constructor with a pre-configured
CloseableHttpAsyncClient instance
and a HttpClientContext supplier lambda which is called before each request
and passed to the client. |
Modifier and Type | Method and Description |
---|---|
void |
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 given
HttpMethod and
URI and apply the given requestCallback when the HTTP
request of the underlying API can be initialized and written to. |
void |
setBufferFactory(DataBufferFactory bufferFactory)
Set the buffer factory to use.
|
public HttpComponentsClientHttpConnector()
CloseableHttpAsyncClient
.public HttpComponentsClientHttpConnector(CloseableHttpAsyncClient client)
CloseableHttpAsyncClient
instance.client
- the client to usepublic HttpComponentsClientHttpConnector(CloseableHttpAsyncClient client, BiFunction<HttpMethod,URI,? extends HttpClientContext> contextProvider)
CloseableHttpAsyncClient
instance
and a HttpClientContext
supplier lambda which is called before each request
and passed to the client.client
- the client to usecontextProvider
- a HttpClientContext
supplierpublic void setBufferFactory(DataBufferFactory bufferFactory)
public reactor.core.publisher.Mono<ClientHttpResponse> connect(HttpMethod method, URI uri, Function<? super ClientHttpRequest,reactor.core.publisher.Mono<Void>> requestCallback)
ClientHttpConnector
HttpMethod
and
URI
and apply the given requestCallback
when the HTTP
request of the underlying API can be initialized and written to.connect
in interface ClientHttpConnector
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 a Mono<Void>
by calling
ReactiveHttpOutputMessage.writeWith(org.reactivestreams.Publisher<? extends org.springframework.core.io.buffer.DataBuffer>)
or ReactiveHttpOutputMessage.setComplete()
.ClientHttpResponse
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException