https://github.com/digipost/http-client-builder
Apache HTTP Client configured with sensible defaults.
https://github.com/digipost/http-client-builder
Last synced: about 2 months ago
JSON representation
Apache HTTP Client configured with sensible defaults.
- Host: GitHub
- URL: https://github.com/digipost/http-client-builder
- Owner: digipost
- License: apache-2.0
- Created: 2016-06-07T20:01:00.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2022-03-29T11:56:32.000Z (about 3 years ago)
- Last Synced: 2025-01-29T05:38:05.139Z (4 months ago)
- Language: Java
- Size: 108 KB
- Stars: 0
- Watchers: 14
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Digipost HTTP Client Builder
[](https://maven-badges.herokuapp.com/maven-central/no.digipost/http-client-builder5)

[](https://github.com/digipost/http-client-builder/blob/main/LICENSE)A tiny library for building instances of [Apache HttpClient](https://hc.apache.org/httpcomponents-client-ga/) configured with sensible defaults.
## Usage
Here are some common use cases to quickly get you started.
Client with sensible defaults:
```java
CloseableHttpClient client = HttpClientFactory.createDefault();
```### Custom ssl context
```java
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:
```java
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.