public class HttpClientConfigurer extends Object
CloseableHttpClient
. This class allows for
chained method invocation. If both basic auth credentials and a target host
are provided, the HTTP client will aggressively send the credentials
without having to receive an HTTP 401 response first.
This class can also be used to configure the client used by
RestTemplate
using
buildClientHttpRequestFactory()
.
Modifier | Constructor and Description |
---|---|
protected |
HttpClientConfigurer(URI targetHost) |
Modifier and Type | Method and Description |
---|---|
HttpClientConfigurer |
addInterceptor(org.apache.http.HttpRequestInterceptor interceptor) |
HttpClientConfigurer |
basicAuthCredentials(String username,
String password) |
ClientHttpRequestFactory |
buildClientHttpRequestFactory() |
org.apache.http.impl.client.CloseableHttpClient |
buildHttpClient() |
static HttpClientConfigurer |
create(URI targetHost) |
HttpClientConfigurer |
skipTlsCertificateVerification()
Sets the client's
SSLContext to use
HttpUtils.buildCertificateIgnoringSslContext() . |
HttpClientConfigurer |
skipTlsCertificateVerification(boolean skipTlsCertificateVerification) |
HttpClientConfigurer |
withProxyCredentials(URI proxyUri,
String proxyUsername,
String proxyPassword)
Configures the
HttpClientBuilder with a proxy host. |
protected HttpClientConfigurer(URI targetHost)
public static HttpClientConfigurer create(URI targetHost)
public HttpClientConfigurer basicAuthCredentials(String username, String password)
public HttpClientConfigurer withProxyCredentials(URI proxyUri, String proxyUsername, String proxyPassword)
HttpClientBuilder
with a proxy host. If the
proxyUsername
and proxyPassword
are not null
then a CredentialsProvider
is also configured for the proxy host.proxyUri
- Must not be null and must be configured with a scheme (http or https).proxyUsername
- May be nullproxyPassword
- May be nullthis
to enable chained method invocationpublic HttpClientConfigurer skipTlsCertificateVerification()
SSLContext
to use
HttpUtils.buildCertificateIgnoringSslContext()
.this
to enable chained method invocationpublic HttpClientConfigurer skipTlsCertificateVerification(boolean skipTlsCertificateVerification)
public HttpClientConfigurer addInterceptor(org.apache.http.HttpRequestInterceptor interceptor)
public org.apache.http.impl.client.CloseableHttpClient buildHttpClient()
public ClientHttpRequestFactory buildClientHttpRequestFactory()
Copyright © 2023 Pivotal Software, Inc.. All rights reserved.