You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2021/09/21 19:45:49 UTC

[httpcomponents-client] branch master updated: HTTPCLIENT-2120: force HTTP/1.1 protocol policy when creating a tunnel via HTTP/1.1 proxy

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/master by this push:
     new 0870824  HTTPCLIENT-2120: force HTTP/1.1 protocol policy when creating a tunnel via HTTP/1.1 proxy
0870824 is described below

commit 087082428e6c3928caefe8370ab186bb93ee28fd
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Tue Sep 21 21:39:51 2021 +0200

    HTTPCLIENT-2120: force HTTP/1.1 protocol policy when creating a tunnel via HTTP/1.1 proxy
---
 .../client5/testing/external/HttpAsyncClientCompatibilityTest.java | 7 +++++++
 .../apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java | 6 +-----
 .../client5/http/impl/nio/PoolingAsyncClientConnectionManager.java | 3 ++-
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
index 763d9c3..c5903c5 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
@@ -95,6 +95,13 @@ public class HttpAsyncClientCompatibilityTest {
                 new HttpAsyncClientCompatibilityTest(
                         HttpVersionPolicy.NEGOTIATE,
                         new HttpHost("https", "test-httpd", 8443), new HttpHost("localhost", 8889),
+                        new UsernamePasswordCredentials("squid", "nopassword".toCharArray())),
+                new HttpAsyncClientCompatibilityTest(
+                        HttpVersionPolicy.FORCE_HTTP_2,
+                        new HttpHost("https", "test-httpd", 8443), new HttpHost("localhost", 8888), null),
+                new HttpAsyncClientCompatibilityTest(
+                        HttpVersionPolicy.FORCE_HTTP_2,
+                        new HttpHost("https", "test-httpd", 8443), new HttpHost("localhost", 8889),
                         new UsernamePasswordCredentials("squid", "nopassword".toCharArray()))
         };
         for (final HttpAsyncClientCompatibilityTest test: tests) {
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 c2b7c5c..2dc8a42 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
@@ -101,11 +101,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);
-        if (route.isTunnelled() && versionPolicy == HttpVersionPolicy.FORCE_HTTP_2) {
-            throw new HttpException("HTTP/2 tunneling not supported");
-        }
-        return route;
+        return routePlanner.determineRoute(httpHost, clientContext);
     }
 
 }
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
index 7c8089d..fec48df 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
@@ -67,6 +67,7 @@ import org.apache.hc.core5.http.nio.HandlerFactory;
 import org.apache.hc.core5.http.nio.command.RequestExecutionCommand;
 import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
 import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http2.HttpVersionPolicy;
 import org.apache.hc.core5.http2.nio.command.PingCommand;
 import org.apache.hc.core5.http2.nio.support.BasicPingHandler;
 import org.apache.hc.core5.http2.ssl.ApplicationProtocol;
@@ -411,7 +412,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
                 localAddress,
                 connectTimeout,
                 handshakeTimeout,
-                attachment,
+                route.isTunnelled() ? HttpVersionPolicy.FORCE_HTTP_1 : attachment,
                 new FutureCallback<ManagedAsyncClientConnection>() {
 
                     @Override