HTTPCLIENT-2120: force HTTP/1.1 protocol policy when creating a tunnel via HTTP/1.1 proxy
This commit is contained in:
parent
9496bb8475
commit
17ebfc529e
|
@ -95,6 +95,13 @@ public class HttpAsyncClientCompatibilityTest {
|
||||||
new HttpAsyncClientCompatibilityTest(
|
new HttpAsyncClientCompatibilityTest(
|
||||||
HttpVersionPolicy.NEGOTIATE,
|
HttpVersionPolicy.NEGOTIATE,
|
||||||
new HttpHost("https", "test-httpd", 8443), new HttpHost("localhost", 8889),
|
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()))
|
new UsernamePasswordCredentials("squid", "nopassword".toCharArray()))
|
||||||
};
|
};
|
||||||
for (final HttpAsyncClientCompatibilityTest test: tests) {
|
for (final HttpAsyncClientCompatibilityTest test: tests) {
|
||||||
|
|
|
@ -101,11 +101,7 @@ public final class InternalHttpAsyncClient extends InternalAbstractHttpAsyncClie
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
HttpRoute determineRoute(final HttpHost httpHost, final HttpClientContext clientContext) throws HttpException {
|
HttpRoute determineRoute(final HttpHost httpHost, final HttpClientContext clientContext) throws HttpException {
|
||||||
final HttpRoute route = routePlanner.determineRoute(httpHost, clientContext);
|
return routePlanner.determineRoute(httpHost, clientContext);
|
||||||
if (route.isTunnelled() && versionPolicy == HttpVersionPolicy.FORCE_HTTP_2) {
|
|
||||||
throw new HttpException("HTTP/2 tunneling not supported");
|
|
||||||
}
|
|
||||||
return route;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.command.RequestExecutionCommand;
|
||||||
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
||||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
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.command.PingCommand;
|
||||||
import org.apache.hc.core5.http2.nio.support.BasicPingHandler;
|
import org.apache.hc.core5.http2.nio.support.BasicPingHandler;
|
||||||
import org.apache.hc.core5.http2.ssl.ApplicationProtocol;
|
import org.apache.hc.core5.http2.ssl.ApplicationProtocol;
|
||||||
|
@ -405,7 +406,12 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
|
||||||
LOG.debug("{} connecting endpoint to {} ({})", ConnPoolSupport.getId(endpoint), host, connectTimeout);
|
LOG.debug("{} connecting endpoint to {} ({})", ConnPoolSupport.getId(endpoint), host, connectTimeout);
|
||||||
}
|
}
|
||||||
final Future<ManagedAsyncClientConnection> connectFuture = connectionOperator.connect(
|
final Future<ManagedAsyncClientConnection> connectFuture = connectionOperator.connect(
|
||||||
connectionInitiator, host, localAddress, connectTimeout, attachment, new FutureCallback<ManagedAsyncClientConnection>() {
|
connectionInitiator,
|
||||||
|
host,
|
||||||
|
localAddress,
|
||||||
|
connectTimeout,
|
||||||
|
route.isTunnelled() ? HttpVersionPolicy.FORCE_HTTP_1 : attachment,
|
||||||
|
new FutureCallback<ManagedAsyncClientConnection>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completed(final ManagedAsyncClientConnection connection) {
|
public void completed(final ManagedAsyncClientConnection connection) {
|
||||||
|
|
Loading…
Reference in New Issue