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.CloseableHttpClientbuild(HttpClientSettings settings) Build a newHttpClientinstance with the given settings applied.withConnectionManagerCustomizer(Consumer<org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder> connectionManagerCustomizer) Return a newHttpComponentsHttpClientBuilderthat applies additional customization to the underlyingPoolingHttpClientConnectionManagerBuilder.withCustomizer(Consumer<org.apache.hc.client5.http.impl.classic.HttpClientBuilder> customizer) Return a newHttpComponentsHttpClientBuilderthat applies additional customization to the underlyingHttpClientBuilder.withDefaultRequestConfigCustomizer(Consumer<org.apache.hc.client5.http.config.RequestConfig.Builder> defaultRequestConfigCustomizer) Return a newHttpComponentsHttpClientBuilderthat applies additional customization to the underlyingRequestConfig.Builderused for default requests.withSocketConfigCustomizer(Consumer<org.apache.hc.core5.http.io.SocketConfig.Builder> socketConfigCustomizer) Return a newHttpComponentsHttpClientBuilderthat applies additional customization to the underlyingSocketConfig.Builder.withTlsSocketStrategyFactory(Function<SslBundle, org.apache.hc.client5.http.ssl.TlsSocketStrategy> tlsSocketStrategyFactory) Return a newHttpComponentsHttpClientBuilderwith a replacementTlsSocketStrategyfactory.
-
Constructor Details
-
HttpComponentsHttpClientBuilder
public HttpComponentsHttpClientBuilder()
-
-
Method Details
-
withCustomizer
public HttpComponentsHttpClientBuilder withCustomizer(Consumer<org.apache.hc.client5.http.impl.classic.HttpClientBuilder> customizer) Return a newHttpComponentsHttpClientBuilderthat applies additional customization to the underlyingHttpClientBuilder.- Parameters:
customizer- the customizer to apply- Returns:
- a new
HttpComponentsHttpClientBuilderinstance
-
withConnectionManagerCustomizer
public HttpComponentsHttpClientBuilder withConnectionManagerCustomizer(Consumer<org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder> connectionManagerCustomizer) Return a newHttpComponentsHttpClientBuilderthat applies additional customization to the underlyingPoolingHttpClientConnectionManagerBuilder.- Parameters:
connectionManagerCustomizer- the customizer to apply- Returns:
- a new
HttpComponentsHttpClientBuilderinstance
-
withSocketConfigCustomizer
public HttpComponentsHttpClientBuilder withSocketConfigCustomizer(Consumer<org.apache.hc.core5.http.io.SocketConfig.Builder> socketConfigCustomizer) Return a newHttpComponentsHttpClientBuilderthat applies additional customization to the underlyingSocketConfig.Builder.- Parameters:
socketConfigCustomizer- the customizer to apply- Returns:
- a new
HttpComponentsHttpClientBuilderinstance
-
withTlsSocketStrategyFactory
public HttpComponentsHttpClientBuilder withTlsSocketStrategyFactory(Function<SslBundle, org.apache.hc.client5.http.ssl.TlsSocketStrategy> tlsSocketStrategyFactory) Return a newHttpComponentsHttpClientBuilderwith a replacementTlsSocketStrategyfactory.- Parameters:
tlsSocketStrategyFactory- the new factory used to create aTlsSocketStrategy. The function will be provided with aSslBundleornullif no bundle is selected. Only nonnullresults will be applied.- Returns:
- a new
HttpComponentsHttpClientBuilderinstance
-
withDefaultRequestConfigCustomizer
public HttpComponentsHttpClientBuilder withDefaultRequestConfigCustomizer(Consumer<org.apache.hc.client5.http.config.RequestConfig.Builder> defaultRequestConfigCustomizer) Return a newHttpComponentsHttpClientBuilderthat applies additional customization to the underlyingRequestConfig.Builderused for default requests.- Parameters:
defaultRequestConfigCustomizer- the customizer to apply- Returns:
- a new
HttpComponentsHttpClientBuilderinstance
-
build
public org.apache.hc.client5.http.impl.classic.CloseableHttpClient build(HttpClientSettings settings) Build a newHttpClientinstance with the given settings applied.- Parameters:
settings- the settings to apply- Returns:
- a new
HttpClientinstance
-