HttpClientConfig
Overview
The HttpClientConfig
object provides configurable properties to manage the behavior of an HTTP client, including settings for SSL/TLS, connection limits, protocol preferences, and user agent configuration. ## Functionality
SSL/TLS and Security
certPath
andcertPassword
specify the client certificate location and password.trustStorePath
andtrustStorePassword
define the truststore for trusted certificates.protocol
sets the TLS protocol, defaulting to TLS.hostValidation
disables hostname validation, primarily for testing purposes.
Connection Management
keepAliveDuration
sets the duration (in seconds) for keeping connections alive.maxConnectionsPerRoute
andmaxTotalConnections
limit the number of connections managed by the client.maxIOThreadCount
determines the number of input/output threads for the client.
Additional Features
enableRedirects
enables or disables automatic following of HTTP redirects.forceHttp1
forces HTTP/1.1 usage when HTTP/2 compatibility issues arise.multiPartLegacyMode
switches multipart request handling to a non-buffered mode.userAgent
allows customization of the HTTP client’s user agent string.
Properties Summarized
Force the use of http1, use this if there are problems connecting to a server that does use http/2 but uses old cipher suites or if there are other problems like http/2 not setting the content length and the server still wants it.
Gets/Sets keep alive duration in seconds for a connection, default is -1 (no duration specified).
Gets/Sets maximum number of connections per route used by Connection Manager.
Gets/Sets maximum number of input/output threads per client, default value is 2.
Sets whether multipart request should be written in one go(not using buffering).
Gets/Sets the password to the java truststore where to import the certificate.
Properties Detailed
certPassword
Gets/Sets the certificate password. The following sample sets up an HttpClient with custom SSL/TLS configuration using a PKCS12 keystore for client certificates and a JKS truststore for trusted certificate authorities.
Type String
Sample
var config = plugins.http.createNewHttpClientConfig();
config.certPath = "";
config.certPassword = "";
config.trustStorePassword = "";
var client = plugins.http.createNewHttpClient(config);
certPath
Gets/Sets the certificate path. The following sample sets up an HttpClient with custom SSL/TLS configuration using a PKCS12 keystore for client certificates and a JKS truststore for trusted certificate authorities.
Type String
Sample
var config = plugins.http.createNewHttpClientConfig();
config.certPath = "";
config.certPassword = "";
config.trustStorePassword = "";
var client = plugins.http.createNewHttpClient(config);
enableRedirects
Sets whether client should follow redirects or you want to do it manually. Default value is true.
Type Boolean
Sample
var config = plugins.http.createNewHttpClientConfig();
config.enableRedirects = false;
var client = plugins.http.createNewHttpClient(config);
forceHttp1
Force the use of http1, use this if there are problems connecting to a server that does use http/2 but uses old cipher suites or if there are other problems like http/2 not setting the content length and the server still wants it.
Type Boolean
Sample
var config = plugins.http.createNewHttpClientConfig();
config.forceHttp1 = true;
var client = plugins.http.createNewHttpClient(config);
hostValidation
Disable hostname certificate validation. This should be used only for testing purposes, because this is not secure!
Type Boolean
Sample
var config = plugins.http.createNewHttpClientConfig();
config.hostValidation = false;
var client = plugins.http.createNewHttpClient(config);
keepAliveDuration
Gets/Sets keep alive duration in seconds for a connection, default is -1 (no duration specified).
Type Number
Sample
var config = plugins.http.createNewHttpClientConfig();
config.keepAliveDuration = 5;
var client = plugins.http.createNewHttpClient(config);
maxConnectionsPerRoute
Gets/Sets maximum number of connections per route used by Connection Manager.
Type Number
Sample
var config = plugins.http.createNewHttpClientConfig();
config.maxConnectionsPerRoute = 2;
var client = plugins.http.createNewHttpClient(config);
maxIOThreadCount
Gets/Sets maximum number of input/output threads per client, default value is 2.
Type Number
Sample
var config = plugins.http.createNewHttpClientConfig();
config.maxIOThreadCount = 5;
var client = plugins.http.createNewHttpClient(config);
maxTotalConnections
Gets/Sets maximum number of connections used by Connection Manager.
Type Number
Sample
var config = plugins.http.createNewHttpClientConfig();
config.maxTotalConnections = 5;
var client = plugins.http.createNewHttpClient(config);
multiPartLegacyMode
Sets whether multipart request should be written in one go(not using buffering). Default value is false.
Type Boolean
Sample
var config = plugins.http.createNewHttpClientConfig();
config.multiPartLegacyMode = true;
var client = plugins.http.createNewHttpClient(config);
protocol
Gets/Sets which TLS protocol to use, default value is TLS.
Type String
Sample
var config = plugins.http.createNewHttpClientConfig();
config.protocol = "TLSv1.2";
var client = plugins.http.createNewHttpClient(config);
trustStorePassword
Gets/Sets the password to the java truststore where to import the certificate. The following sample sets up an HttpClient with custom SSL/TLS configuration using a PKCS12 keystore for client certificates and a JKS truststore for trusted certificate authorities.
Type String
Sample
var config = plugins.http.createNewHttpClientConfig();
config.certPath = "";
config.certPassword = "";
config.trustStorePassword = "";
var client = plugins.http.createNewHttpClient(config);
userAgent
Gets/Sets custom userAgent to use.
Type String
Sample
var config = plugins.http.createNewHttpClientConfig();
config.userAgent = "Mozilla/5.0 Firefox/26.0";
var client = plugins.http.createNewHttpClient(config);
Last updated
Was this helpful?