use of org.apache.hc.client5.http.io.HttpClientConnectionManager in project gradle-download-task by michel-kraemer.
the class DefaultHttpClientFactory method createHttpClient.
@Override
public CloseableHttpClient createHttpClient(HttpHost httpHost, boolean acceptAnyCertificate, final int retries, Logger logger, boolean quiet) {
HttpClientBuilder builder = HttpClientBuilder.create();
// configure retries
if (retries == 0) {
builder.disableAutomaticRetries();
} else {
// TODO make interval configurable
int maxRetries = retries;
if (retries < 0) {
maxRetries = Integer.MAX_VALUE;
}
builder.setRetryStrategy(new CustomHttpRequestRetryStrategy(maxRetries, TimeValue.ofSeconds(0L), logger, quiet));
}
// configure proxy from system environment
builder.setRoutePlanner(new SystemDefaultRoutePlanner(null));
// accept any certificate if necessary
if ("https".equals(httpHost.getSchemeName()) && acceptAnyCertificate) {
SSLConnectionSocketFactory icsf = getInsecureSSLSocketFactory();
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register("https", icsf).register("http", PlainConnectionSocketFactory.INSTANCE).build();
HttpClientConnectionManager cm = new BasicHttpClientConnectionManager(registry);
builder.setConnectionManager(cm);
}
return builder.build();
}
use of org.apache.hc.client5.http.io.HttpClientConnectionManager in project spring-cloud-openfeign by spring-cloud.
the class FeignHttpClient5ConfigurationTests method verifyHc5BeansAvailable.
private static void verifyHc5BeansAvailable(ConfigurableApplicationContext context) {
CloseableHttpClient httpClient = context.getBean(CloseableHttpClient.class);
assertThat(httpClient).isNotNull();
HttpClientConnectionManager connectionManager = context.getBean(HttpClientConnectionManager.class);
assertThat(connectionManager).isInstanceOf(PoolingHttpClientConnectionManager.class);
Client client = context.getBean(Client.class);
assertThat(client).isInstanceOf(ApacheHttp5Client.class);
}
use of org.apache.hc.client5.http.io.HttpClientConnectionManager in project geo-platform by geosdi.
the class GeoSDIHttpClient5 method createClientConnectionManager.
/**
* @return {@link HttpClientConnectionManager}
*/
HttpClientConnectionManager createClientConnectionManager() {
try {
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, (chain, authType) -> true);
SSLConnectionSocketFactory sslSF = new SSLConnectionSocketFactory(builder.build(), NoopHostnameVerifier.INSTANCE);
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", sslSF).build());
cm.setMaxTotal(10);
cm.setDefaultMaxPerRoute(3);
return cm;
} catch (Exception ex) {
ex.printStackTrace();
throw new IllegalStateException(ex);
}
}
use of org.apache.hc.client5.http.io.HttpClientConnectionManager in project geo-platform by geosdi.
the class GPAbstractServerConnector method createClientConnectionManager.
/**
* @return {@link HttpClientConnectionManager}
*/
protected HttpClientConnectionManager createClientConnectionManager() {
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", this.sslConnectionSocketFactory).build());
cm.setMaxTotal(this.pooledConnectorConfig.getMaxTotalConnections());
cm.setDefaultMaxPerRoute(this.pooledConnectorConfig.getDefaultMaxPerRoute());
return cm;
}
use of org.apache.hc.client5.http.io.HttpClientConnectionManager in project commons-vfs by apache.
the class Http5FileProvider method createConnectionManager.
private HttpClientConnectionManager createConnectionManager(final Http5FileSystemConfigBuilder builder, final FileSystemOptions fileSystemOptions) throws FileSystemException {
final SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(Timeout.ofMilliseconds(builder.getSoTimeoutDuration(fileSystemOptions).toMillis())).build();
final String[] tlsVersions = builder.getTlsVersions(fileSystemOptions).split("\\s*,\\s*");
final TLS[] tlsArray = Stream.of(tlsVersions).map(TLS::valueOf).toArray(TLS[]::new);
final SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder.create().setSslContext(createSSLContext(builder, fileSystemOptions)).setHostnameVerifier(createHostnameVerifier(builder, fileSystemOptions)).setTlsVersions(tlsArray).build();
return PoolingHttpClientConnectionManagerBuilder.create().setSSLSocketFactory(sslSocketFactory).setMaxConnTotal(builder.getMaxTotalConnections(fileSystemOptions)).setMaxConnPerRoute(builder.getMaxConnectionsPerHost(fileSystemOptions)).setDefaultSocketConfig(socketConfig).build();
}
Aggregations