Interface HttpClientConfigurer


@Experimental @NoImplement @MinMuleVersion("4.10.0") public interface HttpClientConfigurer
Allows configuring a HttpClient.
Since:
0.12.0
  • Method Details

    • setTlsContextFactory

      HttpClientConfigurer setTlsContextFactory(org.mule.runtime.api.tls.TlsContextFactory tlsContextFactory)
      Required exclusively for HTTPS, this defines through a TlsContextFactory all the TLS related data to establish such connections. Set to null by default.
      Parameters:
      tlsContextFactory - a TlsContextFactory with the required data.
      Returns:
      this configurer
    • setMaxConnections

      HttpClientConfigurer setMaxConnections(int maxConnections)
      Defines the maximum number of outbound connections that will be kept open at the same time. Unlimited by default.
      Parameters:
      maxConnections - number of connections to allow
      Returns:
      this configurer
    • setUsePersistentConnections

      HttpClientConfigurer setUsePersistentConnections(boolean usePersistentConnections)
      Defines if connections should be kept after a request is completed or closed. Default value is true.
      Parameters:
      usePersistentConnections - boolean specifying the decision
      Returns:
      this configurer
    • setConnectionIdleTimeout

      HttpClientConfigurer setConnectionIdleTimeout(int connectionIdleTimeout)
      Defines the number of milliseconds that a connection can remain idle before being closed. Only relevant if persistent connections are used, the default value is 30 seconds.
      Parameters:
      connectionIdleTimeout - timeout value (in milliseconds)
      Returns:
      this configurer
    • setStreaming

      HttpClientConfigurer setStreaming(boolean streaming)
      Defines whether the HTTP response should be streamed, meaning processing will continue as soon as all headers are parsed and the body populated as it arrives. Default is false.

      When streaming is enabled, because of the internal buffer used to hold the arriving body chunks, the response MUST be eventually read or the worker threads handling the chunks will block waiting to allocate them. Likewise, read/write speed differences could cause issues. Buffer size can be customized for these reasons. Additionally, to avoid deadlocks, a hand off to another thread MUST be performed before consuming the response.

      Parameters:
      streaming - whether or not to enable streaming
      Returns:
      this configurer
    • setResponseBufferSize

      HttpClientConfigurer setResponseBufferSize(int responseBufferSize)
      Defines the size of the buffer in bytes used to store the HTTP response, the default value is 10KB.
      Parameters:
      responseBufferSize - buffer size (in bytes)
      Returns:
      this configurer
    • setName

      Defines the name of the HttpClient. Must be specified.
      Parameters:
      name - a String representing the prefix
      Returns:
      this configurer
    • setDecompress

      HttpClientConfigurer setDecompress(Boolean decompress)
      Defines whether responses should be decompressed automatically by the HttpClient, false by default. Note that only GZIP encoding is supported.
      Parameters:
      decompress - whether responses should be decompressed
      Returns:
      this configurer
    • configClientSocketProperties

      HttpClientConfigurer configClientSocketProperties(Consumer<TcpSocketPropertiesConfigurer> configCallback)
      Optionally defines TCP specific properties like the socket connection timeout, for example, via a TcpSocketPropertiesConfigurer.
      Parameters:
      configCallback - a callback to set the tcp properties.
      Returns:
      this configurer
    • configProxy

      HttpClientConfigurer configProxy(Consumer<ProxyConfigurer> configCallback)
      Required when connecting through a proxy, this defines the relevant data to do so using a ProxyConfigurer.
      Parameters:
      configCallback - a callback to configure the ProxyConfigurer
      Returns:
      this configurer
    • configHttp1

      Allows enabling/disabling and configuring HTTP/1 specific parameters.
      Parameters:
      configCallback - a callback to configure the Http1ProtocolConfigurer
      Returns:
      this configurer
    • configHttp2

      Allows enabling/disabling and configuring HTTP/2 specific parameters.
      Parameters:
      configCallback - a callback to configure the Http2ProtocolConfigurer
      Returns:
      this configurer