From b535a2812bb2142b712bfc12a8f4ea7e8ce93246 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Thu, 6 Jun 2019 16:23:43 +0200 Subject: [PATCH] Upgraded HttpCore to version 5.0-beta8 --- .../hc/client5/http/fluent/Request.java | 5 +- .../AbstractSimpleServerExchangeHandler.java | 2 +- .../async/AuthenticatingAsyncDecorator.java | 2 +- .../AbstractHttp1IntegrationTestBase.java | 8 +-- ...AbstractHttpAsyncClientAuthentication.java | 8 +-- .../AbstractHttpAsyncFundamentalsTest.java | 2 +- .../async/AbstractHttpAsyncRedirectsTest.java | 10 ++-- .../async/AbstractIntegrationTestBase.java | 6 +-- .../testing/async/AbstractServerTestBase.java | 6 +-- .../client5/testing/async/TestHttp1Async.java | 4 +- .../TestHttp1AsyncStatefulConnManagement.java | 4 +- .../async/TestHttp1ClientAuthentication.java | 4 +- .../testing/async/TestHttpAsyncMinimal.java | 10 ++-- .../sync/TestMalformedServerResponse.java | 6 +-- .../testing/sync/TestSSLSocketFactory.java | 53 ++++--------------- .../async/methods/AsyncRequestBuilder.java | 2 +- .../async/methods/SimpleRequestProducer.java | 2 +- .../http/entity/UrlEncodedFormEntity.java | 18 +++---- .../async/AbstractHttpAsyncClientBase.java | 7 --- .../impl/async/CloseableHttpAsyncClient.java | 4 -- .../impl/async/Http2AsyncClientBuilder.java | 1 + .../Http2AsyncClientEventHandlerFactory.java | 16 +++--- .../impl/async/HttpAsyncClientBuilder.java | 11 ++-- .../HttpAsyncClientEventHandlerFactory.java | 18 +++---- .../http/impl/async/HttpAsyncClients.java | 12 ++--- .../impl/async/LoggingExceptionCallback.java | 48 +++++++++++++++++ .../http/impl/async/LoggingIOSession.java | 10 ++-- .../impl/async/MinimalHttp2AsyncClient.java | 1 + .../impl/async/MinimalHttpAsyncClient.java | 1 + .../http/impl/classic/ProxyClient.java | 6 +-- .../io/DefaultHttpResponseParserFactory.java | 4 +- .../DefaultManagedHttpClientConnection.java | 4 +- .../impl/io/LenientHttpResponseParser.java | 10 ++-- .../ManagedHttpClientConnectionFactory.java | 12 ++--- .../http/ssl/AbstractClientTlsStrategy.java | 6 ++- .../http/ssl/SSLConnectionSocketFactory.java | 27 ++-------- .../AsyncClientFullDuplexExchange.java | 8 +-- .../examples/AsyncClientHttp1Pipelining.java | 4 +- .../AsyncClientHttp2FullDuplexExchange.java | 4 +- .../examples/AsyncClientHttp2ServerPush.java | 5 -- .../AsyncClientHttpExchangeStreaming.java | 5 -- .../http/examples/AsyncQuickStart.java | 5 -- .../http/examples/ClientConfiguration.java | 8 +-- .../ReactiveClientFullDuplexExchange.java | 6 +-- pom.xml | 2 +- 45 files changed, 188 insertions(+), 209 deletions(-) create mode 100644 httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingExceptionCallback.java diff --git a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java index 2d473275e..850ef6bcf 100644 --- a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java +++ b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java @@ -323,8 +323,9 @@ public class Request { for (final NameValuePair param : formParams) { paramList.add(param); } - final ContentType contentType = ContentType.create(URLEncodedUtils.CONTENT_TYPE, charset); - final String s = URLEncodedUtils.format(paramList, charset); + final ContentType contentType = charset != null ? + ContentType.APPLICATION_FORM_URLENCODED.withCharset(charset) : ContentType.APPLICATION_FORM_URLENCODED; + final String s = URLEncodedUtils.format(paramList, contentType.getCharset()); return bodyString(s, contentType); } diff --git a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AbstractSimpleServerExchangeHandler.java b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AbstractSimpleServerExchangeHandler.java index 650ccebc3..24635acd9 100644 --- a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AbstractSimpleServerExchangeHandler.java +++ b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AbstractSimpleServerExchangeHandler.java @@ -38,12 +38,12 @@ import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.nio.AsyncEntityProducer; import org.apache.hc.core5.http.nio.AsyncRequestConsumer; import org.apache.hc.core5.http.nio.AsyncServerRequestHandler; -import org.apache.hc.core5.http.nio.BasicResponseProducer; import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityConsumer; import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer; import org.apache.hc.core5.http.nio.entity.StringAsyncEntityProducer; import org.apache.hc.core5.http.nio.support.AbstractAsyncRequesterConsumer; import org.apache.hc.core5.http.nio.support.AbstractServerExchangeHandler; +import org.apache.hc.core5.http.nio.support.BasicResponseProducer; import org.apache.hc.core5.http.protocol.HttpContext; import org.apache.hc.core5.http.protocol.HttpCoreContext; diff --git a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AuthenticatingAsyncDecorator.java b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AuthenticatingAsyncDecorator.java index 030bc26c3..ec55db3dd 100644 --- a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AuthenticatingAsyncDecorator.java +++ b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AuthenticatingAsyncDecorator.java @@ -45,11 +45,11 @@ import org.apache.hc.core5.http.message.BasicClassicHttpResponse; import org.apache.hc.core5.http.message.BasicHttpResponse; import org.apache.hc.core5.http.nio.AsyncResponseProducer; import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler; -import org.apache.hc.core5.http.nio.BasicResponseProducer; import org.apache.hc.core5.http.nio.CapacityChannel; import org.apache.hc.core5.http.nio.DataStreamChannel; import org.apache.hc.core5.http.nio.ResponseChannel; import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer; +import org.apache.hc.core5.http.nio.support.BasicResponseProducer; import org.apache.hc.core5.http.protocol.HttpContext; import org.apache.hc.core5.net.URIAuthority; import org.apache.hc.core5.util.Args; diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttp1IntegrationTestBase.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttp1IntegrationTestBase.java index 074f4e368..424b7193b 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttp1IntegrationTestBase.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttp1IntegrationTestBase.java @@ -40,7 +40,7 @@ import org.apache.hc.client5.testing.SSLTestContexts; import org.apache.hc.core5.function.Decorator; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.URIScheme; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.impl.HttpProcessors; import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler; import org.apache.hc.core5.http.protocol.HttpProcessor; @@ -109,7 +109,7 @@ public abstract class AbstractHttp1IntegrationTestBase extends AbstractServerTes public HttpHost start( final HttpProcessor httpProcessor, final Decorator exchangeHandlerDecorator, - final H1Config h1Config) throws Exception { + final Http1Config h1Config) throws Exception { server.start(httpProcessor, exchangeHandlerDecorator, h1Config); final Future endpointFuture = server.listen(new InetSocketAddress(0)); httpclient = clientBuilder.build(); @@ -121,12 +121,12 @@ public abstract class AbstractHttp1IntegrationTestBase extends AbstractServerTes public HttpHost start( final HttpProcessor httpProcessor, - final H1Config h1Config) throws Exception { + final Http1Config h1Config) throws Exception { return start(httpProcessor, null, h1Config); } public HttpHost start() throws Exception { - return start(HttpProcessors.server(), H1Config.DEFAULT); + return start(HttpProcessors.server(), Http1Config.DEFAULT); } } diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java index ff5c34068..ff2041f03 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java @@ -62,7 +62,7 @@ import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.HttpVersion; import org.apache.hc.core5.http.URIScheme; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.config.Lookup; import org.apache.hc.core5.http.config.Registry; import org.apache.hc.core5.http.config.RegistryBuilder; @@ -72,7 +72,7 @@ import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler; import org.apache.hc.core5.http.protocol.HttpContext; import org.apache.hc.core5.http.protocol.HttpCoreContext; import org.apache.hc.core5.http2.config.H2Config; -import org.apache.hc.core5.http2.impl.Http2Processors; +import org.apache.hc.core5.http2.impl.H2Processors; import org.apache.hc.core5.net.URIAuthority; import org.junit.Assert; import org.junit.Test; @@ -102,14 +102,14 @@ public abstract class AbstractHttpAsyncClientAuthentication exchangeHandlerDecorator) throws Exception { if (protocolVersion.greaterEquals(HttpVersion.HTTP_2_0)) { return super.start( - Http2Processors.server(), + H2Processors.server(), exchangeHandlerDecorator, H2Config.DEFAULT); } else { return super.start( HttpProcessors.server(), exchangeHandlerDecorator, - H1Config.DEFAULT); + Http1Config.DEFAULT); } } diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java index 3100812dd..281609e83 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java @@ -47,8 +47,8 @@ import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.Message; import org.apache.hc.core5.http.URIScheme; -import org.apache.hc.core5.http.nio.BasicResponseConsumer; import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityConsumer; +import org.apache.hc.core5.http.nio.support.BasicResponseConsumer; import org.hamcrest.CoreMatchers; import org.junit.Assert; import org.junit.Test; diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java index 9ceafa56f..9f5e72252 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java @@ -57,7 +57,7 @@ import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.HttpVersion; import org.apache.hc.core5.http.ProtocolException; import org.apache.hc.core5.http.URIScheme; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.message.BasicHeader; import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler; import org.apache.hc.core5.http.protocol.HttpCoreContext; @@ -65,7 +65,7 @@ import org.apache.hc.core5.http2.config.H2Config; import org.apache.hc.core5.net.URIBuilder; import org.apache.hc.core5.reactor.IOReactorConfig; import org.apache.hc.core5.reactor.ListenerEndpoint; -import org.apache.hc.core5.testing.nio.Http2TestServer; +import org.apache.hc.core5.testing.nio.H2TestServer; import org.apache.hc.core5.util.TimeValue; import org.junit.Assert; import org.junit.Test; @@ -84,7 +84,7 @@ public abstract class AbstractHttpAsyncRedirectsTest () { @@ -701,7 +701,7 @@ public abstract class AbstractHttpAsyncRedirectsTest endpointFuture = secondServer.listen(new InetSocketAddress(0)); final ListenerEndpoint endpoint2 = endpointFuture.get(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractIntegrationTestBase.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractIntegrationTestBase.java index 422837b8c..03d9a4d29 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractIntegrationTestBase.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractIntegrationTestBase.java @@ -34,7 +34,7 @@ import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient; import org.apache.hc.core5.function.Decorator; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.URIScheme; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler; import org.apache.hc.core5.http.protocol.HttpProcessor; import org.apache.hc.core5.http2.config.H2Config; @@ -75,7 +75,7 @@ public abstract class AbstractIntegrationTestBase exchangeHandlerDecorator, - final H1Config h1Config) throws Exception { + final Http1Config h1Config) throws Exception { server.start(httpProcessor, exchangeHandlerDecorator, h1Config); final Future endpointFuture = server.listen(new InetSocketAddress(0)); httpclient = createClient(); @@ -87,7 +87,7 @@ public abstract class AbstractIntegrationTestBase() { @Override - public void initialize(final SSLServerSocket socket) throws SSLException { - socket.setNeedClientAuth(true); + public void execute(final SSLParameters sslParameters) { + sslParameters.setNeedClientAuth(true); } }) @@ -302,47 +302,16 @@ public class TestSSLSocketFactory { } } - @Test - public void testTLSOnly() throws Exception { - // @formatter:off - this.server = ServerBootstrap.bootstrap() - .setSslContext(SSLTestContexts.createServerSSLContext()) - .setSslSetupHandler(new SSLServerSetupHandler() { - - @Override - public void initialize(final SSLServerSocket socket) throws SSLException { - socket.setEnabledProtocols(new String[] {"TLSv1"}); - } - - }) - .create(); - // @formatter:on - this.server.start(); - - final HttpContext context = new BasicHttpContext(); - final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory( - SSLTestContexts.createClientSSLContext()); - try (final Socket socket = socketFactory.createSocket(context)) { - final InetSocketAddress remoteAddress = new InetSocketAddress("localhost", this.server.getLocalPort()); - final HttpHost target = new HttpHost("https", "localhost", this.server.getLocalPort()); - try (final SSLSocket sslSocket = (SSLSocket) socketFactory.connectSocket(TimeValue.ZERO_MILLISECONDS, socket, target, remoteAddress, - null, context)) { - final SSLSession sslsession = sslSocket.getSession(); - Assert.assertNotNull(sslsession); - } - } - } - @Test(expected = IOException.class) public void testSSLDisabledByDefault() throws Exception { // @formatter:off this.server = ServerBootstrap.bootstrap() .setSslContext(SSLTestContexts.createServerSSLContext()) - .setSslSetupHandler(new SSLServerSetupHandler() { + .setSslSetupHandler(new Callback() { @Override - public void initialize(final SSLServerSocket socket) throws SSLException { - socket.setEnabledProtocols(new String[] {"SSLv3"}); + public void execute(final SSLParameters sslParameters) { + sslParameters.setProtocols(new String[] {"SSLv3"}); } }) @@ -393,11 +362,11 @@ public class TestSSLSocketFactory { // @formatter:off this.server = ServerBootstrap.bootstrap() .setSslContext(SSLTestContexts.createServerSSLContext()) - .setSslSetupHandler(new SSLServerSetupHandler() { + .setSslSetupHandler(new Callback() { @Override - public void initialize(final SSLServerSocket socket) { - socket.setEnabledCipherSuites(new String[] {cipherSuite}); + public void execute(final SSLParameters sslParameters) { + sslParameters.setProtocols(new String[] {cipherSuite}); } }) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java index 5c9d1a97c..33d5f62e7 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AsyncRequestBuilder.java @@ -47,9 +47,9 @@ import org.apache.hc.core5.http.message.BasicNameValuePair; import org.apache.hc.core5.http.message.HeaderGroup; import org.apache.hc.core5.http.nio.AsyncEntityProducer; import org.apache.hc.core5.http.nio.AsyncRequestProducer; -import org.apache.hc.core5.http.nio.BasicRequestProducer; import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer; import org.apache.hc.core5.http.nio.entity.StringAsyncEntityProducer; +import org.apache.hc.core5.http.nio.support.BasicRequestProducer; import org.apache.hc.core5.net.URIBuilder; import org.apache.hc.core5.net.URLEncodedUtils; import org.apache.hc.core5.util.Args; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleRequestProducer.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleRequestProducer.java index 4e5dc9273..d6e78a5f7 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleRequestProducer.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleRequestProducer.java @@ -27,9 +27,9 @@ package org.apache.hc.client5.http.async.methods; import org.apache.hc.core5.http.nio.AsyncEntityProducer; -import org.apache.hc.core5.http.nio.BasicRequestProducer; import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer; import org.apache.hc.core5.http.nio.entity.StringAsyncEntityProducer; +import org.apache.hc.core5.http.nio.support.BasicRequestProducer; import org.apache.hc.core5.util.Args; /** diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/UrlEncodedFormEntity.java b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/UrlEncodedFormEntity.java index c058c2579..9e18a775b 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/UrlEncodedFormEntity.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/UrlEncodedFormEntity.java @@ -27,7 +27,6 @@ package org.apache.hc.client5.http.entity; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import java.util.List; import org.apache.hc.core5.http.ContentType; @@ -52,17 +51,18 @@ public class UrlEncodedFormEntity extends StringEntity { * * @since 4.2 */ - public UrlEncodedFormEntity ( - final Iterable parameters, - final Charset charset) { - super(URLEncodedUtils.format(parameters, - charset != null ? charset : StandardCharsets.ISO_8859_1), - ContentType.create(URLEncodedUtils.CONTENT_TYPE, charset)); + public UrlEncodedFormEntity( + final Iterable parameters, + final Charset charset) { + super(URLEncodedUtils.format( + parameters, + charset != null ? charset : ContentType.APPLICATION_FORM_URLENCODED.getCharset()), + charset != null ? ContentType.APPLICATION_FORM_URLENCODED.withCharset(charset) : ContentType.APPLICATION_FORM_URLENCODED); } /** * Constructs a new {@link UrlEncodedFormEntity} with the list - * of parameters with the default encoding of {@link StandardCharsets#ISO_8859_1} + * of parameters with the default encoding of {@link ContentType#APPLICATION_FORM_URLENCODED} * * @param parameters list of name/value pairs */ @@ -72,7 +72,7 @@ public class UrlEncodedFormEntity extends StringEntity { /** * Constructs a new {@link UrlEncodedFormEntity} with the list - * of parameters with the default encoding of {@link StandardCharsets#ISO_8859_1} + * of parameters with the default encoding of {@link ContentType#APPLICATION_FORM_URLENCODED} * * @param parameters iterable collection of name/value pairs * diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java index 4c9be8815..916bd07f0 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java @@ -26,7 +26,6 @@ */ package org.apache.hc.client5.http.impl.async; -import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; @@ -37,7 +36,6 @@ import org.apache.hc.core5.http.nio.AsyncPushConsumer; import org.apache.hc.core5.io.CloseMode; import org.apache.hc.core5.reactor.ConnectionInitiator; import org.apache.hc.core5.reactor.DefaultConnectingIOReactor; -import org.apache.hc.core5.reactor.ExceptionEvent; import org.apache.hc.core5.reactor.IOReactorStatus; import org.apache.hc.core5.util.TimeValue; import org.slf4j.Logger; @@ -101,11 +99,6 @@ abstract class AbstractHttpAsyncClientBase extends CloseableHttpAsyncClient { return ioReactor.getStatus(); } - @Override - public final List getExceptionLog() { - return ioReactor.getExceptionLog(); - } - @Override public final void awaitShutdown(final TimeValue waitTime) throws InterruptedException { ioReactor.awaitShutdown(waitTime); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java index 46bbbb83b..b42f4574b 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java @@ -27,7 +27,6 @@ package org.apache.hc.client5.http.impl.async; import java.io.Closeable; -import java.util.List; import java.util.concurrent.Future; import org.apache.hc.client5.http.async.HttpAsyncClient; @@ -46,7 +45,6 @@ import org.apache.hc.core5.http.nio.AsyncRequestProducer; import org.apache.hc.core5.http.nio.AsyncResponseConsumer; import org.apache.hc.core5.http.protocol.HttpContext; import org.apache.hc.core5.io.CloseMode; -import org.apache.hc.core5.reactor.ExceptionEvent; import org.apache.hc.core5.reactor.IOReactorStatus; import org.apache.hc.core5.util.Args; import org.apache.hc.core5.util.TimeValue; @@ -63,8 +61,6 @@ public abstract class CloseableHttpAsyncClient implements HttpAsyncClient, Close public abstract IOReactorStatus getStatus(); - public abstract List getExceptionLog(); - public abstract void awaitShutdown(TimeValue waitTime) throws InterruptedException; public abstract void initiateShutdown(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientBuilder.java index ed38cfe89..7df8fc36a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientBuilder.java @@ -721,6 +721,7 @@ public class Http2AsyncClientBuilder { ioReactorConfig != null ? ioReactorConfig : IOReactorConfig.DEFAULT, threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true), null, + LoggingExceptionCallback.INSTANCE, null, new Callback() { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientEventHandlerFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientEventHandlerFactory.java index 15b50698e..4849ba3fb 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientEventHandlerFactory.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientEventHandlerFactory.java @@ -40,9 +40,9 @@ import org.apache.hc.core5.http.protocol.HttpProcessor; import org.apache.hc.core5.http2.config.H2Config; import org.apache.hc.core5.http2.frame.FramePrinter; import org.apache.hc.core5.http2.frame.RawFrame; -import org.apache.hc.core5.http2.impl.nio.ClientHttp2StreamMultiplexerFactory; -import org.apache.hc.core5.http2.impl.nio.Http2OnlyClientProtocolNegotiator; -import org.apache.hc.core5.http2.impl.nio.Http2StreamListener; +import org.apache.hc.core5.http2.impl.nio.ClientH2StreamMultiplexerFactory; +import org.apache.hc.core5.http2.impl.nio.H2OnlyClientProtocolNegotiator; +import org.apache.hc.core5.http2.impl.nio.H2StreamListener; import org.apache.hc.core5.reactor.IOEventHandler; import org.apache.hc.core5.reactor.IOEventHandlerFactory; import org.apache.hc.core5.reactor.ProtocolIOSession; @@ -84,12 +84,12 @@ class Http2AsyncClientEventHandlerFactory implements IOEventHandlerFactory { || framePayloadLog.isDebugEnabled() || flowCtrlLog.isDebugEnabled()) { final String id = ConnPoolSupport.getId(ioSession); - final ClientHttp2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientHttp2StreamMultiplexerFactory( + final ClientH2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientH2StreamMultiplexerFactory( httpProcessor, exchangeHandlerFactory, h2Config, charCodingConfig, - new Http2StreamListener() { + new H2StreamListener() { final FramePrinter framePrinter = new FramePrinter(); @@ -173,15 +173,15 @@ class Http2AsyncClientEventHandlerFactory implements IOEventHandlerFactory { }); final LoggingIOSession loggingIOSession = new LoggingIOSession(ioSession, id, sessionLog, wireLog); - return new Http2OnlyClientProtocolNegotiator(loggingIOSession, http2StreamHandlerFactory, false); + return new H2OnlyClientProtocolNegotiator(loggingIOSession, http2StreamHandlerFactory, false); } - final ClientHttp2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientHttp2StreamMultiplexerFactory( + final ClientH2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientH2StreamMultiplexerFactory( httpProcessor, exchangeHandlerFactory, h2Config, charCodingConfig, null); - return new Http2OnlyClientProtocolNegotiator(ioSession, http2StreamHandlerFactory, false); + return new H2OnlyClientProtocolNegotiator(ioSession, http2StreamHandlerFactory, false); } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java index 2d009449b..67c0f32ae 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java @@ -94,7 +94,7 @@ import org.apache.hc.core5.http.HttpRequestInterceptor; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponseInterceptor; import org.apache.hc.core5.http.config.CharCodingConfig; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.config.Lookup; import org.apache.hc.core5.http.config.NamedElementChain; import org.apache.hc.core5.http.config.RegistryBuilder; @@ -211,7 +211,7 @@ public class HttpAsyncClientBuilder { private AsyncClientConnectionManager connManager; private boolean connManagerShared; private IOReactorConfig ioReactorConfig; - private H1Config h1Config; + private Http1Config h1Config; private H2Config h2Config; private CharCodingConfig charCodingConfig; private SchemePortResolver schemePortResolver; @@ -271,9 +271,9 @@ public class HttpAsyncClientBuilder { } /** - * Sets {@link H1Config} configuration. + * Sets {@link Http1Config} configuration. */ - public final HttpAsyncClientBuilder setH1Config(final H1Config h1Config) { + public final HttpAsyncClientBuilder setHttp1Config(final Http1Config h1Config) { this.h1Config = h1Config; return this; } @@ -920,7 +920,7 @@ public class HttpAsyncClientBuilder { }, versionPolicy != null ? versionPolicy : HttpVersionPolicy.NEGOTIATE, h2Config != null ? h2Config : H2Config.DEFAULT, - h1Config != null ? h1Config : H1Config.DEFAULT, + h1Config != null ? h1Config : Http1Config.DEFAULT, charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT, reuseStrategyCopy); final DefaultConnectingIOReactor ioReactor = new DefaultConnectingIOReactor( @@ -928,6 +928,7 @@ public class HttpAsyncClientBuilder { ioReactorConfig != null ? ioReactorConfig : IOReactorConfig.DEFAULT, threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true), null, + LoggingExceptionCallback.INSTANCE, null, new Callback() { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java index 51028ca46..c89db2a73 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java @@ -38,7 +38,7 @@ import org.apache.hc.core5.http.HttpConnection; import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.config.CharCodingConfig; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy; import org.apache.hc.core5.http.impl.Http1StreamListener; import org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexerFactory; @@ -55,9 +55,9 @@ import org.apache.hc.core5.http2.HttpVersionPolicy; import org.apache.hc.core5.http2.config.H2Config; import org.apache.hc.core5.http2.frame.FramePrinter; import org.apache.hc.core5.http2.frame.RawFrame; -import org.apache.hc.core5.http2.impl.nio.ClientHttp2StreamMultiplexerFactory; +import org.apache.hc.core5.http2.impl.nio.ClientH2StreamMultiplexerFactory; import org.apache.hc.core5.http2.impl.nio.ClientHttpProtocolNegotiator; -import org.apache.hc.core5.http2.impl.nio.Http2StreamListener; +import org.apache.hc.core5.http2.impl.nio.H2StreamListener; import org.apache.hc.core5.reactor.IOEventHandler; import org.apache.hc.core5.reactor.IOEventHandlerFactory; import org.apache.hc.core5.reactor.ProtocolIOSession; @@ -78,7 +78,7 @@ class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory { private final HandlerFactory exchangeHandlerFactory; private final HttpVersionPolicy versionPolicy; private final H2Config h2Config; - private final H1Config h1Config; + private final Http1Config h1Config; private final CharCodingConfig charCodingConfig; private final ConnectionReuseStrategy http1ConnectionReuseStrategy; private final NHttpMessageParserFactory http1ResponseParserFactory; @@ -89,14 +89,14 @@ class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory { final HandlerFactory exchangeHandlerFactory, final HttpVersionPolicy versionPolicy, final H2Config h2Config, - final H1Config h1Config, + final Http1Config h1Config, final CharCodingConfig charCodingConfig, final ConnectionReuseStrategy connectionReuseStrategy) { this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor"); this.exchangeHandlerFactory = exchangeHandlerFactory; this.versionPolicy = versionPolicy != null ? versionPolicy : HttpVersionPolicy.NEGOTIATE; this.h2Config = h2Config != null ? h2Config : H2Config.DEFAULT; - this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT; + this.h1Config = h1Config != null ? h1Config : Http1Config.DEFAULT; this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT; this.http1ConnectionReuseStrategy = connectionReuseStrategy != null ? connectionReuseStrategy : DefaultConnectionReuseStrategy.INSTANCE; this.http1ResponseParserFactory = new DefaultHttpResponseParserFactory(h1Config); @@ -155,12 +155,12 @@ class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory { } }); - final ClientHttp2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientHttp2StreamMultiplexerFactory( + final ClientH2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientH2StreamMultiplexerFactory( httpProcessor, exchangeHandlerFactory, h2Config, charCodingConfig, - new Http2StreamListener() { + new H2StreamListener() { final FramePrinter framePrinter = new FramePrinter(); @@ -258,7 +258,7 @@ class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory { http1ResponseParserFactory, http1RequestWriterFactory, null); - final ClientHttp2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientHttp2StreamMultiplexerFactory( + final ClientH2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientH2StreamMultiplexerFactory( httpProcessor, exchangeHandlerFactory, h2Config, diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClients.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClients.java index 4c2040355..83c354671 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClients.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClients.java @@ -38,7 +38,7 @@ import org.apache.hc.core5.concurrent.DefaultThreadFactory; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.config.CharCodingConfig; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy; import org.apache.hc.core5.http.nio.AsyncPushConsumer; import org.apache.hc.core5.http.nio.HandlerFactory; @@ -150,7 +150,7 @@ public final class HttpAsyncClients { public static MinimalHttpAsyncClient createMinimal( final HttpVersionPolicy versionPolicy, final H2Config h2Config, - final H1Config h1Config, + final Http1Config h1Config, final IOReactorConfig ioReactorConfig, final AsyncClientConnectionManager connmgr) { final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry(); @@ -185,7 +185,7 @@ public final class HttpAsyncClients { public static MinimalHttpAsyncClient createMinimal( final HttpVersionPolicy versionPolicy, final H2Config h2Config, - final H1Config h1Config, + final Http1Config h1Config, final IOReactorConfig ioReactorConfig) { return createMinimal(versionPolicy, h2Config, h1Config, ioReactorConfig, PoolingAsyncClientConnectionManagerBuilder.create().build()); @@ -196,7 +196,7 @@ public final class HttpAsyncClients { * HTTP/1.1 and HTTP/2 message transport without advanced HTTP protocol * functionality. */ - public static MinimalHttpAsyncClient createMinimal(final H2Config h2Config, final H1Config h1Config) { + public static MinimalHttpAsyncClient createMinimal(final H2Config h2Config, final Http1Config h1Config) { return createMinimal(HttpVersionPolicy.NEGOTIATE, h2Config, h1Config, IOReactorConfig.DEFAULT); } @@ -206,7 +206,7 @@ public final class HttpAsyncClients { * functionality. */ public static MinimalHttpAsyncClient createMinimal() { - return createMinimal(H2Config.DEFAULT, H1Config.DEFAULT); + return createMinimal(H2Config.DEFAULT, Http1Config.DEFAULT); } /** @@ -218,7 +218,7 @@ public final class HttpAsyncClients { return createMinimal( HttpVersionPolicy.NEGOTIATE, H2Config.DEFAULT, - H1Config.DEFAULT, + Http1Config.DEFAULT, IOReactorConfig.DEFAULT, connManager); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingExceptionCallback.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingExceptionCallback.java new file mode 100644 index 000000000..911b00c81 --- /dev/null +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingExceptionCallback.java @@ -0,0 +1,48 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.hc.client5.http.impl.async; + +import org.apache.hc.core5.function.Callback; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class LoggingExceptionCallback implements Callback { + + static LoggingExceptionCallback INSTANCE = new LoggingExceptionCallback(); + + private final Logger log = LoggerFactory.getLogger("org.apache.hc.client5.http.impl.async"); + + private LoggingExceptionCallback() { + } + + @Override + public void execute(final Exception ex) { + log.error(ex.getMessage(), ex); + } + +} diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingIOSession.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingIOSession.java index 44a27f05c..a0256c81f 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingIOSession.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingIOSession.java @@ -80,11 +80,6 @@ class LoggingIOSession implements ProtocolIOSession { return this.session.getLock(); } - @Override - public Lock lock() { - return this.session.lock(); - } - @Override public boolean hasCommands() { return this.session.hasCommands(); @@ -222,6 +217,11 @@ class LoggingIOSession implements ProtocolIOSession { this.session.updateWriteTime(); } + @Override + public long getLastEventTime() { + return this.session.getLastEventTime(); + } + @Override public IOEventHandler getHandler() { return this.session.getHandler(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttp2AsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttp2AsyncClient.java index 356355a6c..6f728e1aa 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttp2AsyncClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttp2AsyncClient.java @@ -106,6 +106,7 @@ public final class MinimalHttp2AsyncClient extends AbstractMinimalHttpAsyncClien reactorConfig, workerThreadFactory, null, + LoggingExceptionCallback.INSTANCE, null, new Callback() { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java index 2deaf90a5..53df7a04c 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java @@ -116,6 +116,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient reactorConfig, workerThreadFactory, null, + LoggingExceptionCallback.INSTANCE, null, new Callback() { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProxyClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProxyClient.java index 5088cf43b..edbece2f0 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProxyClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProxyClient.java @@ -37,11 +37,11 @@ import org.apache.hc.client5.http.RouteInfo.TunnelType; import org.apache.hc.client5.http.SystemDefaultDnsResolver; import org.apache.hc.client5.http.auth.AuthExchange; import org.apache.hc.client5.http.auth.AuthSchemeProvider; +import org.apache.hc.client5.http.auth.AuthSchemes; import org.apache.hc.client5.http.auth.AuthScope; import org.apache.hc.client5.http.auth.ChallengeType; import org.apache.hc.client5.http.auth.Credentials; import org.apache.hc.client5.http.auth.KerberosConfig; -import org.apache.hc.client5.http.auth.AuthSchemes; import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy; import org.apache.hc.client5.http.impl.TunnelRefusedException; @@ -64,7 +64,7 @@ import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.config.CharCodingConfig; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.config.Lookup; import org.apache.hc.core5.http.config.RegistryBuilder; import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy; @@ -102,7 +102,7 @@ public class ProxyClient { */ public ProxyClient( final HttpConnectionFactory connFactory, - final H1Config h1Config, + final Http1Config h1Config, final CharCodingConfig charCodingConfig, final RequestConfig requestConfig) { super(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpResponseParserFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpResponseParserFactory.java index f61eeb721..108b293bd 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpResponseParserFactory.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpResponseParserFactory.java @@ -31,7 +31,7 @@ import org.apache.hc.core5.annotation.Contract; import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.HttpResponseFactory; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.impl.io.DefaultClassicHttpResponseFactory; import org.apache.hc.core5.http.io.HttpMessageParser; import org.apache.hc.core5.http.io.HttpMessageParserFactory; @@ -68,7 +68,7 @@ public class DefaultHttpResponseParserFactory implements HttpMessageParserFactor } @Override - public HttpMessageParser create(final H1Config h1Config) { + public HttpMessageParser create(final Http1Config h1Config) { return new LenientHttpResponseParser(this.lineParser, this.responseFactory, h1Config); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultManagedHttpClientConnection.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultManagedHttpClientConnection.java index 19a4a1b0f..226647b56 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultManagedHttpClientConnection.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultManagedHttpClientConnection.java @@ -42,7 +42,7 @@ import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.ContentLengthStrategy; import org.apache.hc.core5.http.Header; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection; import org.apache.hc.core5.http.impl.io.SocketHolder; import org.apache.hc.core5.http.io.HttpMessageParserFactory; @@ -71,7 +71,7 @@ final class DefaultManagedHttpClientConnection final String id, final CharsetDecoder charDecoder, final CharsetEncoder charEncoder, - final H1Config h1Config, + final Http1Config h1Config, final ContentLengthStrategy incomingContentStrategy, final ContentLengthStrategy outgoingContentStrategy, final HttpMessageWriterFactory requestWriterFactory, diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LenientHttpResponseParser.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LenientHttpResponseParser.java index 4a0c246dd..a4d617b5d 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LenientHttpResponseParser.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/LenientHttpResponseParser.java @@ -32,7 +32,7 @@ import java.io.IOException; import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpResponseFactory; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.impl.io.DefaultHttpResponseParser; import org.apache.hc.core5.http.message.LineParser; import org.apache.hc.core5.util.CharArrayBuffer; @@ -57,25 +57,25 @@ public class LenientHttpResponseParser extends DefaultHttpResponseParser { * @param responseFactory HTTP response factory. If {@code null} * {@link org.apache.hc.core5.http.impl.io.DefaultClassicHttpResponseFactory#INSTANCE} * will be used. - * @param h1Config HTTP/1.1 parameters. If {@code null}. {@link H1Config#DEFAULT} will be used. + * @param h1Config HTTP/1.1 parameters. If {@code null}. {@link Http1Config#DEFAULT} will be used. * * @since 4.3 */ public LenientHttpResponseParser( final LineParser lineParser, final HttpResponseFactory responseFactory, - final H1Config h1Config) { + final Http1Config h1Config) { super(lineParser, responseFactory, h1Config); } /** * Creates new instance of DefaultHttpResponseParser. * - * @param h1Config HTTP/1.1 parameters. If {@code null}. {@link H1Config#DEFAULT} will be used. + * @param h1Config HTTP/1.1 parameters. If {@code null}. {@link Http1Config#DEFAULT} will be used. * * @since 4.3 */ - public LenientHttpResponseParser(final H1Config h1Config) { + public LenientHttpResponseParser(final Http1Config h1Config) { this(null, null, h1Config); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java index 7dd373f4f..63ae378de 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java @@ -42,7 +42,7 @@ import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.ContentLengthStrategy; import org.apache.hc.core5.http.config.CharCodingConfig; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy; import org.apache.hc.core5.http.impl.io.DefaultHttpRequestWriterFactory; import org.apache.hc.core5.http.io.HttpConnectionFactory; @@ -60,7 +60,7 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory public static final ManagedHttpClientConnectionFactory INSTANCE = new ManagedHttpClientConnectionFactory(); - private final H1Config h1Config; + private final Http1Config h1Config; private final CharCodingConfig charCodingConfig; private final HttpMessageWriterFactory requestWriterFactory; private final HttpMessageParserFactory responseParserFactory; @@ -68,14 +68,14 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory private final ContentLengthStrategy outgoingContentStrategy; public ManagedHttpClientConnectionFactory( - final H1Config h1Config, + final Http1Config h1Config, final CharCodingConfig charCodingConfig, final HttpMessageWriterFactory requestWriterFactory, final HttpMessageParserFactory responseParserFactory, final ContentLengthStrategy incomingContentStrategy, final ContentLengthStrategy outgoingContentStrategy) { super(); - this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT; + this.h1Config = h1Config != null ? h1Config : Http1Config.DEFAULT; this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT; this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory : DefaultHttpRequestWriterFactory.INSTANCE; @@ -88,7 +88,7 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory } public ManagedHttpClientConnectionFactory( - final H1Config h1Config, + final Http1Config h1Config, final CharCodingConfig charCodingConfig, final HttpMessageWriterFactory requestWriterFactory, final HttpMessageParserFactory responseParserFactory) { @@ -96,7 +96,7 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory } public ManagedHttpClientConnectionFactory( - final H1Config h1Config, + final Http1Config h1Config, final CharCodingConfig charCodingConfig, final HttpMessageParserFactory responseParserFactory) { this(h1Config, charCodingConfig, null, responseParserFactory); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategy.java index ed694e8ca..239c14ce1 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategy.java @@ -41,6 +41,8 @@ import org.apache.hc.core5.annotation.Contract; import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.nio.ssl.TlsStrategy; +import org.apache.hc.core5.http.ssl.TLS; +import org.apache.hc.core5.http.ssl.TlsCiphers; import org.apache.hc.core5.http2.HttpVersionPolicy; import org.apache.hc.core5.http2.ssl.H2TlsSupport; import org.apache.hc.core5.net.NamedEndpoint; @@ -101,12 +103,12 @@ abstract class AbstractClientTlsStrategy implements TlsStrategy { if (supportedProtocols != null) { sslParameters.setProtocols(supportedProtocols); } else if (versionPolicy != HttpVersionPolicy.FORCE_HTTP_1) { - sslParameters.setProtocols(H2TlsSupport.excludeBlacklistedProtocols(sslParameters.getProtocols())); + sslParameters.setProtocols(TLS.excludeWeak(sslParameters.getProtocols())); } if (supportedCipherSuites != null) { sslParameters.setCipherSuites(supportedCipherSuites); } else if (versionPolicy != HttpVersionPolicy.FORCE_HTTP_1) { - sslParameters.setCipherSuites(H2TlsSupport.excludeBlacklistedCiphers(sslParameters.getCipherSuites())); + sslParameters.setCipherSuites(TlsCiphers.excludeH2Blacklisted(sslParameters.getCipherSuites())); } if (versionPolicy != HttpVersionPolicy.FORCE_HTTP_1) { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java index 35cdf784b..fe373c7d4 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java @@ -31,7 +31,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.InetSocketAddress; import java.net.Socket; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -50,6 +49,8 @@ import org.apache.hc.core5.annotation.Contract; import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.protocol.HttpContext; +import org.apache.hc.core5.http.ssl.TLS; +import org.apache.hc.core5.http.ssl.TlsCiphers; import org.apache.hc.core5.io.Closer; import org.apache.hc.core5.ssl.SSLContexts; import org.apache.hc.core5.ssl.SSLInitializationException; @@ -238,32 +239,12 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor if (supportedProtocols != null) { sslsock.setEnabledProtocols(supportedProtocols); } else { - // If supported protocols are not explicitly set, remove all SSL protocol versions - final String[] allProtocols = sslsock.getEnabledProtocols(); - final List enabledProtocols = new ArrayList<>(allProtocols.length); - for (final String protocol: allProtocols) { - if (!protocol.startsWith("SSL")) { - enabledProtocols.add(protocol); - } - } - if (!enabledProtocols.isEmpty()) { - sslsock.setEnabledProtocols(enabledProtocols.toArray(new String[enabledProtocols.size()])); - } + sslsock.setEnabledProtocols((TLS.excludeWeak(sslsock.getEnabledProtocols()))); } if (supportedCipherSuites != null) { sslsock.setEnabledCipherSuites(supportedCipherSuites); } else { - // If cipher suites are not explicitly set, remove all insecure ones - final String[] allCipherSuites = sslsock.getEnabledCipherSuites(); - final List enabledCipherSuites = new ArrayList<>(allCipherSuites.length); - for (final String cipherSuite : allCipherSuites) { - if (!isWeakCipherSuite(cipherSuite)) { - enabledCipherSuites.add(cipherSuite); - } - } - if (!enabledCipherSuites.isEmpty()) { - sslsock.setEnabledCipherSuites(enabledCipherSuites.toArray(new String[enabledCipherSuites.size()])); - } + sslsock.setEnabledCipherSuites(TlsCiphers.excludeWeak(sslsock.getEnabledCipherSuites())); } if (this.log.isDebugEnabled()) { diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientFullDuplexExchange.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientFullDuplexExchange.java index a0d965a05..1481e01b2 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientFullDuplexExchange.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientFullDuplexExchange.java @@ -40,15 +40,15 @@ import org.apache.hc.core5.http.EntityDetails; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpResponse; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler; -import org.apache.hc.core5.http.nio.BasicRequestProducer; -import org.apache.hc.core5.http.nio.BasicResponseConsumer; import org.apache.hc.core5.http.nio.CapacityChannel; import org.apache.hc.core5.http.nio.DataStreamChannel; import org.apache.hc.core5.http.nio.RequestChannel; import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer; import org.apache.hc.core5.http.nio.entity.StringAsyncEntityConsumer; +import org.apache.hc.core5.http.nio.support.BasicRequestProducer; +import org.apache.hc.core5.http.nio.support.BasicResponseConsumer; import org.apache.hc.core5.http.protocol.HttpContext; import org.apache.hc.core5.http2.HttpVersionPolicy; import org.apache.hc.core5.http2.config.H2Config; @@ -70,7 +70,7 @@ public class AsyncClientFullDuplexExchange { final MinimalHttpAsyncClient client = HttpAsyncClients.createMinimal( HttpVersionPolicy.NEGOTIATE, H2Config.DEFAULT, - H1Config.DEFAULT, + Http1Config.DEFAULT, ioReactorConfig); client.start(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java index 77afa34f2..9c3d3778c 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java @@ -39,7 +39,7 @@ import org.apache.hc.client5.http.impl.async.HttpAsyncClients; import org.apache.hc.client5.http.impl.async.MinimalHttpAsyncClient; import org.apache.hc.core5.concurrent.FutureCallback; import org.apache.hc.core5.http.HttpHost; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.nio.AsyncClientEndpoint; import org.apache.hc.core5.http2.HttpVersionPolicy; import org.apache.hc.core5.io.CloseMode; @@ -58,7 +58,7 @@ public class AsyncClientHttp1Pipelining { .build(); final MinimalHttpAsyncClient client = HttpAsyncClients.createMinimal( - HttpVersionPolicy.FORCE_HTTP_1, null, H1Config.DEFAULT, ioReactorConfig); + HttpVersionPolicy.FORCE_HTTP_1, null, Http1Config.DEFAULT, ioReactorConfig); client.start(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2FullDuplexExchange.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2FullDuplexExchange.java index 9599ddb76..9cc783de8 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2FullDuplexExchange.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2FullDuplexExchange.java @@ -41,13 +41,13 @@ import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler; -import org.apache.hc.core5.http.nio.BasicRequestProducer; -import org.apache.hc.core5.http.nio.BasicResponseConsumer; import org.apache.hc.core5.http.nio.CapacityChannel; import org.apache.hc.core5.http.nio.DataStreamChannel; import org.apache.hc.core5.http.nio.RequestChannel; import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer; import org.apache.hc.core5.http.nio.entity.StringAsyncEntityConsumer; +import org.apache.hc.core5.http.nio.support.BasicRequestProducer; +import org.apache.hc.core5.http.nio.support.BasicResponseConsumer; import org.apache.hc.core5.http.protocol.HttpContext; import org.apache.hc.core5.http2.HttpVersionPolicy; import org.apache.hc.core5.http2.config.H2Config; diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java index bbb17b002..12fcd5318 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java @@ -146,11 +146,6 @@ public class AsyncClientHttp2ServerPush { System.out.println(requestURI + "->" + cause); } - @Override - public Void getResult() { - return null; - } - @Override public void releaseResources() { } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java index 4a955b9b9..92673e398 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java @@ -95,11 +95,6 @@ public class AsyncClientHttpExchangeStreaming { return null; } - @Override - public Void getResult() { - return null; - } - @Override public void failed(final Exception cause) { System.out.println(requestUri + "->" + cause); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java index c7a0ae70f..ef40eba13 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java @@ -115,11 +115,6 @@ public class AsyncQuickStart { return response; } - @Override - public HttpResponse getResult() { - return response; - } - @Override public void releaseResources() { } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConfiguration.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConfiguration.java index 54db78e83..b063f7cb5 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConfiguration.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConfiguration.java @@ -41,9 +41,9 @@ import org.apache.hc.client5.http.SystemDefaultDnsResolver; import org.apache.hc.client5.http.auth.AuthSchemes; import org.apache.hc.client5.http.auth.CredentialsProvider; import org.apache.hc.client5.http.classic.methods.HttpGet; -import org.apache.hc.client5.http.cookie.CookieSpecs; import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.cookie.BasicCookieStore; +import org.apache.hc.client5.http.cookie.CookieSpecs; import org.apache.hc.client5.http.cookie.CookieStore; import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; @@ -62,7 +62,7 @@ import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.ParseException; import org.apache.hc.core5.http.config.CharCodingConfig; -import org.apache.hc.core5.http.config.H1Config; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.config.Registry; import org.apache.hc.core5.http.config.RegistryBuilder; import org.apache.hc.core5.http.impl.io.DefaultClassicHttpResponseFactory; @@ -98,7 +98,7 @@ public class ClientConfiguration { final HttpMessageParserFactory responseParserFactory = new DefaultHttpResponseParserFactory() { @Override - public HttpMessageParser create(final H1Config h1Config) { + public HttpMessageParser create(final Http1Config h1Config) { final LineParser lineParser = new BasicLineParser() { @Override @@ -118,7 +118,7 @@ public class ClientConfiguration { final HttpMessageWriterFactory requestWriterFactory = new DefaultHttpRequestWriterFactory(); // Create HTTP/1.1 protocol configuration - final H1Config h1Config = H1Config.custom() + final Http1Config h1Config = Http1Config.custom() .setMaxHeaderCount(200) .setMaxLineLength(2000) .build(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ReactiveClientFullDuplexExchange.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ReactiveClientFullDuplexExchange.java index 2f2abdebf..9803e2ce4 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ReactiveClientFullDuplexExchange.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ReactiveClientFullDuplexExchange.java @@ -38,8 +38,8 @@ import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.Message; -import org.apache.hc.core5.http.config.H1Config; -import org.apache.hc.core5.http.nio.BasicRequestProducer; +import org.apache.hc.core5.http.config.Http1Config; +import org.apache.hc.core5.http.nio.support.BasicRequestProducer; import org.apache.hc.core5.http2.HttpVersionPolicy; import org.apache.hc.core5.http2.config.H2Config; import org.apache.hc.core5.io.CloseMode; @@ -69,7 +69,7 @@ public class ReactiveClientFullDuplexExchange { final MinimalHttpAsyncClient client = HttpAsyncClients.createMinimal( HttpVersionPolicy.NEGOTIATE, H2Config.DEFAULT, - H1Config.DEFAULT, + Http1Config.DEFAULT, ioReactorConfig); client.start(); diff --git a/pom.xml b/pom.xml index 76777e518..fc3dd68e5 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ 1.7 1.7 - 5.0-beta7 + 5.0-beta8 2.9.1 1.12 1.4.1