Class HttpClientConfig


  • public final class HttpClientConfig
    extends Object

    A class collecting all configuration options supported by the HTTP client library.

    An object of this class is needed to create a new HttpClient instance. There is a default instance available, which can be adapted by changing configuration options. Instances are immutable; changing an option returns a modified copy.

    • Method Detail

      • basicConfig

        public static HttpClientConfig basicConfig()
        Returns a basic HttpClientConfig instance. This instance contains a minimum configuration. It can be used for simple use cases or serve as a starting point for constructing custom configurations.
        Returns:
        the basic configuration instance
      • customObjectMapper

        public Optional<com.fasterxml.jackson.databind.ObjectMapper> customObjectMapper()
        Returns an Optional with a custom JSON object mapper to be used for dealing with JSON payload. If this Optional is empty, a new mapper (without a special configuration) is created and used by the HTTP client.
        Returns:
        an Optional with a custom JSON object mapper
      • getOrCreateObjectMapper

        public com.fasterxml.jackson.databind.ObjectMapper getOrCreateObjectMapper()
        Returns an ObjectMapper instance that is either the custom mapper which has been set explicitly or a newly created instance. This method can be used to obtain a correct and non-null JSON mapper instance.
        Returns:
        the JSON mapper configured by this class
      • proxySettings

        public ProxySettings proxySettings()
        Returns a ProxySettings object with the proxy configuration to be used.
        Returns:
        the proxy configuration for the HTTP library
      • withObjectMapper

        public HttpClientConfig withObjectMapper​(com.fasterxml.jackson.databind.ObjectMapper newMapper)
        Returns a new instance of HttpClientConfig that contains the same settings as this instance, but with the JSON object mapper set to the parameter specified.
        Parameters:
        newMapper - the JSON object mapper (can be null to remove a special custom object mapper)
        Returns:
        the new HttpClientConfig instance
      • withProxySettings

        public HttpClientConfig withProxySettings​(ProxySettings newProxySettings)
        Returns a new instance of HttpClientConfig that contains the same settings as this instance, but with the proxy configuration set to the parameter specified.
        Parameters:
        newProxySettings - the proxy configuration to be set
        Returns:
        the new HttpClientConfig instance
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object