Allows configuring a
HttpClient.- Since:
- 0.12.0
-
Method Summary
Modifier and TypeMethodDescriptionconfigClientSocketProperties(Consumer<TcpSocketPropertiesConfigurer> configCallback) Optionally defines TCP specific properties like the socket connection timeout, for example, via aTcpSocketPropertiesConfigurer.configHttp1(Consumer<Http1ProtocolConfigurer> configCallback) Allows enabling/disabling and configuring HTTP/1 specific parameters.configHttp2(Consumer<Http2ProtocolConfigurer> configCallback) Allows enabling/disabling and configuring HTTP/2 specific parameters.configProxy(Consumer<ProxyConfigurer> configCallback) Required when connecting through a proxy, this defines the relevant data to do so using aProxyConfigurer.setConnectionIdleTimeout(int connectionIdleTimeout) Defines the number of milliseconds that a connection can remain idle before being closed.setDecompress(Boolean decompress) Defines whether responses should be decompressed automatically by theHttpClient,falseby default.setMaxConnections(int maxConnections) Defines the maximum number of outbound connections that will be kept open at the same time.Defines the name of theHttpClient.setResponseBufferSize(int responseBufferSize) Defines the size of the buffer in bytes used to store the HTTP response, the default value is 10KB.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.setTlsContextFactory(org.mule.runtime.api.tls.TlsContextFactory tlsContextFactory) Required exclusively for HTTPS, this defines through aTlsContextFactoryall the TLS related data to establish such connections.setUsePersistentConnections(boolean usePersistentConnections) Defines if connections should be kept after a request is completed or closed.
-
Method Details
-
setTlsContextFactory
HttpClientConfigurer setTlsContextFactory(org.mule.runtime.api.tls.TlsContextFactory tlsContextFactory) Required exclusively for HTTPS, this defines through aTlsContextFactoryall the TLS related data to establish such connections. Set tonullby default.- Parameters:
tlsContextFactory- aTlsContextFactorywith the required data.- Returns:
- this configurer
-
setMaxConnections
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
Defines if connections should be kept after a request is completed or closed. Default value istrue.- Parameters:
usePersistentConnections-booleanspecifying the decision- Returns:
- this configurer
-
setConnectionIdleTimeout
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
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 isfalse. 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
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 theHttpClient. Must be specified.- Parameters:
name- aStringrepresenting the prefix- Returns:
- this configurer
-
setDecompress
Defines whether responses should be decompressed automatically by theHttpClient,falseby 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 aTcpSocketPropertiesConfigurer.- Parameters:
configCallback- a callback to set the tcp properties.- Returns:
- this configurer
-
configProxy
Required when connecting through a proxy, this defines the relevant data to do so using aProxyConfigurer.- Parameters:
configCallback- a callback to configure theProxyConfigurer- Returns:
- this configurer
-
configHttp1
Allows enabling/disabling and configuring HTTP/1 specific parameters.- Parameters:
configCallback- a callback to configure theHttp1ProtocolConfigurer- Returns:
- this configurer
-
configHttp2
Allows enabling/disabling and configuring HTTP/2 specific parameters.- Parameters:
configCallback- a callback to configure theHttp2ProtocolConfigurer- Returns:
- this configurer
-