Skip to content

Commit

Permalink
Update Apache AsyncHttpClient
Browse files Browse the repository at this point in the history
  • Loading branch information
jenschude committed Dec 12, 2024
1 parent de78e1b commit 7b63ac3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions commercetools/commercetools-apachehttp-client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

dependencies {
api project(":rmf:rmf-java-base")
api "org.apache.httpcomponents.client5:httpclient5:5.3.1" version {
api "org.apache.httpcomponents.client5:httpclient5:5.4.1" version {
strictly "[5.0,6.0["
prefer "5.1.3"
prefer "5.4.1"
}

api commons.io version commons.io_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.hc.client5.http.async.methods.SimpleBody;
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer;
import org.apache.hc.client5.http.config.TlsConfig;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder;
import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder;
Expand All @@ -32,7 +33,6 @@
import org.apache.hc.core5.http.nio.support.AsyncRequestBuilder;
import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.reactor.IOReactorStatus;
import org.apache.hc.core5.reactor.ssl.TlsDetails;

public class CtApacheHttpClient extends HttpClientBase {
public static final int MAX_REQUESTS = 64;
Expand All @@ -46,19 +46,19 @@ public static HttpAsyncClientBuilder createClientBuilder() {
}

public static HttpAsyncClientBuilder createClientBuilder(AsyncClientConnectionManager cm) {
return HttpAsyncClientBuilder.create().setVersionPolicy(HttpVersionPolicy.NEGOTIATE).setConnectionManager(cm);
return HttpAsyncClientBuilder.create().setConnectionManager(cm);
}

public static PoolingAsyncClientConnectionManagerBuilder createConnectionManager(final int maxConnTotal,
final int maxConnPerRoute) {
final TlsStrategy tlsStrategy = ClientTlsStrategyBuilder.create()
.useSystemProperties()
.setTlsDetailsFactory(
sslEngine -> new TlsDetails(sslEngine.getSession(), sslEngine.getApplicationProtocol()))
final TlsStrategy tlsStrategy = ClientTlsStrategyBuilder.create().useSystemProperties().build();
final TlsConfig tlsConfig = TlsConfig.copy(TlsConfig.DEFAULT)
.setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.build();
return PoolingAsyncClientConnectionManagerBuilder.create()
.setMaxConnPerRoute(maxConnPerRoute)
.setMaxConnTotal(maxConnTotal)
.setDefaultTlsConfig(tlsConfig)
.setTlsStrategy(tlsStrategy);
}

Expand Down

0 comments on commit 7b63ac3

Please sign in to comment.