Class HttpComponentsHttpClientBuilder
java.lang.Object
org.springframework.boot.http.client.HttpComponentsHttpClientBuilder
Builder that can be used to create a
Apache HttpComponents
HttpClient
.- Since:
- 3.5.0
- Author:
- Phillip Webb, Andy Wilkinson, Scott Frederick
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hc.client5.http.impl.classic.CloseableHttpClient
build
(HttpClientSettings settings) Build a newHttpClient
instance with the given settings applied.withConnectionManagerCustomizer
(Consumer<org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder> connectionManagerCustomizer) Return a newHttpComponentsHttpClientBuilder
that applies additional customization to the underlyingPoolingHttpClientConnectionManagerBuilder
.withCustomizer
(Consumer<org.apache.hc.client5.http.impl.classic.HttpClientBuilder> customizer) Return a newHttpComponentsHttpClientBuilder
that applies additional customization to the underlyingHttpClientBuilder
.withDefaultRequestConfigCustomizer
(Consumer<org.apache.hc.client5.http.config.RequestConfig.Builder> defaultRequestConfigCustomizer) Return a newHttpComponentsHttpClientBuilder
that applies additional customization to the underlyingRequestConfig.Builder
used for default requests.withSocketConfigCustomizer
(Consumer<org.apache.hc.core5.http.io.SocketConfig.Builder> socketConfigCustomizer) Return a newHttpComponentsHttpClientBuilder
that applies additional customization to the underlyingSocketConfig.Builder
.withTlsSocketStrategyFactory
(Function<SslBundle, org.apache.hc.client5.http.ssl.TlsSocketStrategy> tlsSocketStrategyFactory) Return a newHttpComponentsHttpClientBuilder
with a replacementTlsSocketStrategy
factory.
-
Constructor Details
-
HttpComponentsHttpClientBuilder
public HttpComponentsHttpClientBuilder()
-
-
Method Details
-
withCustomizer
public HttpComponentsHttpClientBuilder withCustomizer(Consumer<org.apache.hc.client5.http.impl.classic.HttpClientBuilder> customizer) Return a newHttpComponentsHttpClientBuilder
that applies additional customization to the underlyingHttpClientBuilder
.- Parameters:
customizer
- the customizer to apply- Returns:
- a new
HttpComponentsHttpClientBuilder
instance
-
withConnectionManagerCustomizer
public HttpComponentsHttpClientBuilder withConnectionManagerCustomizer(Consumer<org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder> connectionManagerCustomizer) Return a newHttpComponentsHttpClientBuilder
that applies additional customization to the underlyingPoolingHttpClientConnectionManagerBuilder
.- Parameters:
connectionManagerCustomizer
- the customizer to apply- Returns:
- a new
HttpComponentsHttpClientBuilder
instance
-
withSocketConfigCustomizer
public HttpComponentsHttpClientBuilder withSocketConfigCustomizer(Consumer<org.apache.hc.core5.http.io.SocketConfig.Builder> socketConfigCustomizer) Return a newHttpComponentsHttpClientBuilder
that applies additional customization to the underlyingSocketConfig.Builder
.- Parameters:
socketConfigCustomizer
- the customizer to apply- Returns:
- a new
HttpComponentsHttpClientBuilder
instance
-
withTlsSocketStrategyFactory
public HttpComponentsHttpClientBuilder withTlsSocketStrategyFactory(Function<SslBundle, org.apache.hc.client5.http.ssl.TlsSocketStrategy> tlsSocketStrategyFactory) Return a newHttpComponentsHttpClientBuilder
with a replacementTlsSocketStrategy
factory.- Parameters:
tlsSocketStrategyFactory
- the new factory used to create aTlsSocketStrategy
for a givenSslBundle
- Returns:
- a new
HttpComponentsHttpClientBuilder
instance
-
withDefaultRequestConfigCustomizer
public HttpComponentsHttpClientBuilder withDefaultRequestConfigCustomizer(Consumer<org.apache.hc.client5.http.config.RequestConfig.Builder> defaultRequestConfigCustomizer) Return a newHttpComponentsHttpClientBuilder
that applies additional customization to the underlyingRequestConfig.Builder
used for default requests.- Parameters:
defaultRequestConfigCustomizer
- the customizer to apply- Returns:
- a new
HttpComponentsHttpClientBuilder
instance
-
build
public org.apache.hc.client5.http.impl.classic.CloseableHttpClient build(HttpClientSettings settings) Build a newHttpClient
instance with the given settings applied.- Parameters:
settings
- the settings to apply- Returns:
- a new
HttpClient
instance
-