use of org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder in project ksql by confluentinc.
the class DefaultConnectClient method buildHttpClient.
/**
* Uses defaults from Request.execute(), except with an explicit SSLSocketFactory to pass
* custom SSL configs. Link to default below:
* https://github.com/apache/httpcomponents-client/blob/3734aaa038a58c17af638e9fa29019cacb22e82c/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java#L62-L72
*/
private static CloseableHttpClient buildHttpClient(final Optional<SSLContext> sslContext, final boolean verifySslHostname) {
final PoolingHttpClientConnectionManagerBuilder connectionManagerBuilder = PoolingHttpClientConnectionManagerBuilder.create();
sslContext.ifPresent(ctx -> {
final SSLConnectionSocketFactory socketFactory = verifySslHostname ? new SSLConnectionSocketFactory(ctx) : new SSLConnectionSocketFactory(ctx, (hostname, session) -> true);
connectionManagerBuilder.setSSLSocketFactory(socketFactory);
});
return HttpClientBuilder.create().setConnectionManager(connectionManagerBuilder.setMaxConnPerRoute(100).setMaxConnTotal(200).setValidateAfterInactivity(TimeValue.ofSeconds(10L)).build()).useSystemProperties().evictExpiredConnections().evictIdleConnections(TimeValue.ofMinutes(1L)).build();
}
Aggregations