Skip to content

Repository files navigation

Digipost HTTP Client Builder

Maven CentralLicense

A tiny library for building instances of Apache HttpClient configured with sensible defaults.

Usage

Here are some common use cases to quickly get you started.

Client with sensible defaults:

CloseableHttpClientclient = HttpClientFactory.createDefault();

Custom ssl context

PoolingHttpClientConnectionManagerconnectionManager = HttpClientConnectionManagerFactory
.createDefaultBuilder()
.setSSLSocketFactory(
SSLConnectionSocketFactoryBuilder.create()
.setSslContext(getSslContext())
.setTlsVersions(TLS.V_1_3)
.build()
)
.build();
CloseableHttpClientclient = HttpClientFactory.create(connectionManager);

Disable connection monitor

The connection monitor evicts idle and expired connections. It is by default started when the client is built.

It can be disabled by the following code:

CloseableHttpClientclient = HttpClientFactory.create(HttpClientSettings.DEFAULT.connectionEvictionPolicy(ConnectionEvictionPolicy.NONE));

PS: If connection monitor is not disabled, and a new connection manager is set after the client builder has been created (i.e clientBuilder.setConnectionManager(other)), the 'old' connection monitor will still run and monitor the old connection manager.

About

Apache HTTP Client configured with sensible defaults.

Resources

Stars

0 stars

Watchers

11 watching

Forks

Releases

Packages

Used by

Contributors

Languages