Digipost HTTP Client Builder

Apache HTTP Client configured with sensible defaults.

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

no.digipost
ArtifactId

ArtifactId

http-client-builder
Last Version

Last Version

2.0
Release Date

Release Date

Type

Type

jar
Description

Description

Digipost HTTP Client Builder
Apache HTTP Client configured with sensible defaults.
Project URL

Project URL

https://github.com/digipost/http-client-builder
Project Organization

Project Organization

Digipost
Source Code Management

Source Code Management

https://github.com/digipost/http-client-builder

Download http-client-builder

How to add to project

<!-- https://jarcasting.com/artifacts/no.digipost/http-client-builder/ -->
<dependency>
    <groupId>no.digipost</groupId>
    <artifactId>http-client-builder</artifactId>
    <version>2.0</version>
</dependency>
// https://jarcasting.com/artifacts/no.digipost/http-client-builder/
implementation 'no.digipost:http-client-builder:2.0'
// https://jarcasting.com/artifacts/no.digipost/http-client-builder/
implementation ("no.digipost:http-client-builder:2.0")
'no.digipost:http-client-builder:jar:2.0'
<dependency org="no.digipost" name="http-client-builder" rev="2.0">
  <artifact name="http-client-builder" type="jar" />
</dependency>
@Grapes(
@Grab(group='no.digipost', module='http-client-builder', version='2.0')
)
libraryDependencies += "no.digipost" % "http-client-builder" % "2.0"
[no.digipost/http-client-builder "2.0"]

Dependencies

compile (6)

Group / Artifact Type Version
org.apache.httpcomponents : httpclient jar 4.5.2
org.apache.httpcomponents : httpcore jar 4.4.4
org.slf4j : slf4j-api jar 1.7.21
junit : junit jar 4.12
org.hamcrest : hamcrest-library jar 1.3
org.hamcrest : hamcrest-core jar 1.3

runtime (1)

Group / Artifact Type Version
org.slf4j : jcl-over-slf4j jar 1.7.21

Project Modules

There are no modules declared in this project.

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.

no.digipost

Digipost

Digipost er Norges digitale postsystem utviklet av Posten Norge AS.

Versions

Version
2.0