use of org.apache.hc.core5.http.message.BasicHeader in project bender by Nextdoor.
the class AbstractHttp2TransportFactory method getClientBuilder.
protected HttpAsyncClientBuilder getClientBuilder(boolean useSSL, String url, Map<String, String> stringHeaders) {
HttpAsyncClientBuilder cb = HttpAsyncClients.custom();
PoolingAsyncClientConnectionManagerBuilder cmb = PoolingAsyncClientConnectionManagerBuilder.create();
/*
* Setup SSL
*/
if (useSSL) {
final ClientTlsStrategyBuilder tsb = ClientTlsStrategyBuilder.create().setSslContext(getSSLContext()).setTlsVersions(TLS.V_1_3, TLS.V_1_2).setHostnameVerifier(new HostnameVerifier() {
public boolean verify(String s, SSLSession sslSession) {
return true;
}
});
cmb = cmb.setTlsStrategy(tsb.build());
}
/*
* Add default headers
*/
ArrayList<BasicHeader> headers = new ArrayList<BasicHeader>(stringHeaders.size());
stringHeaders.forEach((k, v) -> headers.add(new BasicHeader(k, v)));
cb = cb.setDefaultHeaders(headers);
/*
* Pool concurrency settings
*/
cmb = cmb.setMaxConnPerRoute(this.config.getThreads()).setMaxConnTotal(this.config.getThreads()).setPoolConcurrencyPolicy(PoolConcurrencyPolicy.STRICT);
/*
* Negotiate on HTTP version with the server
*/
cb = cb.setVersionPolicy(HttpVersionPolicy.NEGOTIATE);
return cb.setConnectionManager(cmb.build());
}
Aggregations