Class HttpClientConfigurer

java.lang.Object
org.springframework.cloud.dataflow.rest.util.HttpClientConfigurer

public class HttpClientConfigurer extends Object
Utility for configuring a 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().

Author:
Mike Heath, Gunnar Hillert
  • Constructor Details

    • HttpClientConfigurer

      protected HttpClientConfigurer(URI targetHost)
  • Method Details

    • create

      public static HttpClientConfigurer create(URI targetHost)
    • basicAuthCredentials

      public HttpClientConfigurer basicAuthCredentials(String username, String password)
    • withProxyCredentials

      public HttpClientConfigurer withProxyCredentials(URI proxyUri, String proxyUsername, String proxyPassword)
      Configures the HttpClientBuilder with a proxy host. If the proxyUsername and proxyPassword are not null then a CredentialsProvider is also configured for the proxy host.
      Parameters:
      proxyUri - Must not be null and must be configured with a scheme (http or https).
      proxyUsername - May be null
      proxyPassword - May be null
      Returns:
      a reference to this to enable chained method invocation
    • skipTlsCertificateVerification

      public HttpClientConfigurer skipTlsCertificateVerification()
      Returns:
      a reference to this to enable chained method invocation
    • skipTlsCertificateVerification

      public HttpClientConfigurer skipTlsCertificateVerification(boolean skipTlsCertificateVerification)
    • addInterceptor

      public HttpClientConfigurer addInterceptor(org.apache.hc.core5.http.HttpRequestInterceptor interceptor)
    • buildHttpClient

      public org.apache.hc.client5.http.impl.classic.CloseableHttpClient buildHttpClient()
    • buildClientHttpRequestFactory

      public ClientHttpRequestFactory buildClientHttpRequestFactory()