# 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` and `certPassword` specify the client certificate location and password.
* `trustStorePath` and `trustStorePassword` 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` and `maxTotalConnections` 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

| Type                                                                           | Name                                              | Summary                                                                                                                                                                                                                                |
| ------------------------------------------------------------------------------ | ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [certPassword](#certpassword)                     | Gets/Sets the certificate password.                                                                                                                                                                                                    |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [certPath](#certpath)                             | Gets/Sets the certificate path.                                                                                                                                                                                                        |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) | [enableRedirects](#enableredirects)               | Sets whether client should follow redirects or you want to do it manually.                                                                                                                                                             |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) | [forceHttp1](#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. |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) | [hostValidation](#hostvalidation)                 | Disable hostname certificate validation.                                                                                                                                                                                               |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)   | [keepAliveDuration](#keepaliveduration)           | Gets/Sets keep alive duration in seconds for a connection, default is -1 (no duration specified).                                                                                                                                      |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)   | [maxConnectionsPerRoute](#maxconnectionsperroute) | Gets/Sets maximum number of connections per route used by Connection Manager.                                                                                                                                                          |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)   | [maxIOThreadCount](#maxiothreadcount)             | Gets/Sets maximum number of input/output threads per client, default value is 2.                                                                                                                                                       |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)   | [maxTotalConnections](#maxtotalconnections)       | Gets/Sets maximum number of connections used by Connection Manager.                                                                                                                                                                    |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) | [multiPartLegacyMode](#multipartlegacymode)       | Sets whether multipart request should be written in one go(not using buffering).                                                                                                                                                       |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [protocol](#protocol)                             | Gets/Sets which TLS protocol to use, default value is TLS.                                                                                                                                                                             |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [trustStorePassword](#truststorepassword)         | Gets/Sets the password to the java truststore where to import the certificate.                                                                                                                                                         |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)   | [userAgent](#useragent)                           | Gets/Sets custom userAgent to use.                                                                                                                                                                                                     |

## 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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

**Sample**

```js
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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

**Sample**

```js
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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

**Sample**

```js
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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

**Sample**

```js
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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

**Sample**

```js
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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

**Sample**

```js
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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

**Sample**

```js
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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

**Sample**

```js
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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

**Sample**

```js
var config = plugins.http.createNewHttpClientConfig();
config.userAgent = "Mozilla/5.0 Firefox/26.0";
var client = plugins.http.createNewHttpClient(config);
```

***
