Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digipost HTTP Client Builder

Maven Central License

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:

CloseableHttpClient client = HttpClientFactory.createDefault();

Custom ssl context

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

CloseableHttpClient client = 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:

CloseableHttpClient client = 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