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

**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](/reference/servoycore/dev-api/js-lib/string.md)

**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](/reference/servoycore/dev-api/js-lib/boolean.md)

**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](/reference/servoycore/dev-api/js-lib/boolean.md)

**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](/reference/servoycore/dev-api/js-lib/boolean.md)

**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](/reference/servoycore/dev-api/js-lib/number.md)

**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](/reference/servoycore/dev-api/js-lib/number.md)

**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](/reference/servoycore/dev-api/js-lib/number.md)

**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](/reference/servoycore/dev-api/js-lib/number.md)

**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](/reference/servoycore/dev-api/js-lib/boolean.md)

**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](/reference/servoycore/dev-api/js-lib/string.md)

**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](/reference/servoycore/dev-api/js-lib/string.md)

**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](/reference/servoycore/dev-api/js-lib/string.md)

**Sample**

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

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/reference/servoyextensions/server-plugins/http/httpclientconfig.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
