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
ConstructorsConstructorDescriptionDefault constructor that creates and starts a new instance ofCloseableHttpAsyncClient.Constructor with a pre-configuredCloseableHttpAsyncClientinstance.HttpComponentsClientHttpConnector(CloseableHttpAsyncClient client, BiFunction<HttpMethod, URI, ? extends HttpClientContext> contextProvider) Constructor with a pre-configuredCloseableHttpAsyncClientinstance and aHttpClientContextsupplier lambda which is called before each request and passed to the client. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()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 givenHttpMethodandURIand apply the givenrequestCallbackwhen the HTTP request of the underlying API can be initialized and written to.voidsetBufferFactory(org.springframework.core.io.buffer.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-configuredCloseableHttpAsyncClientinstance.- Parameters:
client- the client to use
-
HttpComponentsClientHttpConnector
public HttpComponentsClientHttpConnector(CloseableHttpAsyncClient client, BiFunction<HttpMethod, URI, ? extends HttpClientContext> contextProvider) Constructor with a pre-configuredCloseableHttpAsyncClientinstance and aHttpClientContextsupplier lambda which is called before each request and passed to the client.- Parameters:
client- the client to usecontextProvider- aHttpClientContextsupplier
-
-
Method Details
-
setBufferFactory
public void setBufferFactory(org.springframework.core.io.buffer.DataBufferFactory bufferFactory) 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: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(org.reactivestreams.Publisher<? extends org.springframework.core.io.buffer.DataBuffer>)orReactiveHttpOutputMessage.setComplete().- Returns:
- publisher for the
ClientHttpResponse
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-