From 1026a1e55880f59a2dafb654347cc120f234ceaf Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Thu, 22 Oct 2020 17:38:43 +0200 Subject: [PATCH] HTTPCLIENT-2122: async client to throw `HTTP/2 tunneling not supported` protocol exception in case of `force HTTP/2` version policy used along with request proxy routing --- .../hc/client5/http/impl/async/InternalHttpAsyncClient.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java index 42518aac1..c2b7c5c69 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java @@ -45,8 +45,6 @@ import org.apache.hc.core5.annotation.Internal; import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHost; -import org.apache.hc.core5.http.HttpVersion; -import org.apache.hc.core5.http.ProtocolVersion; import org.apache.hc.core5.http.config.Lookup; import org.apache.hc.core5.http.nio.AsyncPushConsumer; import org.apache.hc.core5.http.nio.HandlerFactory; @@ -104,8 +102,7 @@ public final class InternalHttpAsyncClient extends InternalAbstractHttpAsyncClie @Override HttpRoute determineRoute(final HttpHost httpHost, final HttpClientContext clientContext) throws HttpException { final HttpRoute route = routePlanner.determineRoute(httpHost, clientContext); - final ProtocolVersion protocolVersion = clientContext.getProtocolVersion(); - if (route.isTunnelled() && protocolVersion.greaterEquals(HttpVersion.HTTP_2_0)) { + if (route.isTunnelled() && versionPolicy == HttpVersionPolicy.FORCE_HTTP_2) { throw new HttpException("HTTP/2 tunneling not supported"); } return route;