Upgraded HttpCore to version 5.0-beta8

This commit is contained in:
Oleg Kalnichevski 2019-06-06 16:23:43 +02:00
parent a0aa438be8
commit b535a2812b
45 changed files with 188 additions and 209 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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;

View File

@ -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<AsyncServerExchangeHandler> exchangeHandlerDecorator,
final H1Config h1Config) throws Exception {
final Http1Config h1Config) throws Exception {
server.start(httpProcessor, exchangeHandlerDecorator, h1Config);
final Future<ListenerEndpoint> 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);
}
}

View File

@ -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<T extends CloseableH
final Decorator<AsyncServerExchangeHandler> 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);
}
}

View File

@ -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;

View File

@ -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 <T extends CloseableHttpAsy
if (version.greaterEquals(HttpVersion.HTTP_2)) {
return super.start(null, H2Config.DEFAULT);
} else {
return super.start(null, H1Config.DEFAULT);
return super.start(null, Http1Config.DEFAULT);
}
}
@ -686,7 +686,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends CloseableHttpAsy
});
final HttpHost redirectTarget = start();
final Http2TestServer secondServer = new Http2TestServer(IOReactorConfig.DEFAULT,
final H2TestServer secondServer = new H2TestServer(IOReactorConfig.DEFAULT,
scheme == URIScheme.HTTPS ? SSLTestContexts.createServerSSLContext() : null);
try {
secondServer.register("/redirect/*", new Supplier<AsyncServerExchangeHandler>() {
@ -701,7 +701,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends CloseableHttpAsy
if (version.greaterEquals(HttpVersion.HTTP_2)) {
secondServer.start(H2Config.DEFAULT);
} else {
secondServer.start(H1Config.DEFAULT);
secondServer.start(Http1Config.DEFAULT);
}
final Future<ListenerEndpoint> endpointFuture = secondServer.listen(new InetSocketAddress(0));
final ListenerEndpoint endpoint2 = endpointFuture.get();

View File

@ -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<T extends CloseableHttpAsyncCl
public final HttpHost start(
final HttpProcessor httpProcessor,
final Decorator<AsyncServerExchangeHandler> exchangeHandlerDecorator,
final H1Config h1Config) throws Exception {
final Http1Config h1Config) throws Exception {
server.start(httpProcessor, exchangeHandlerDecorator, h1Config);
final Future<ListenerEndpoint> endpointFuture = server.listen(new InetSocketAddress(0));
httpclient = createClient();
@ -87,7 +87,7 @@ public abstract class AbstractIntegrationTestBase<T extends CloseableHttpAsyncCl
public final HttpHost start(
final HttpProcessor httpProcessor,
final H1Config h1Config) throws Exception {
final Http1Config h1Config) throws Exception {
return start(httpProcessor, null, h1Config);
}

View File

@ -32,7 +32,7 @@ import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
import org.apache.hc.core5.reactor.IOReactorConfig;
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.apache.hc.core5.util.Timeout;
import org.junit.Rule;
@ -53,14 +53,14 @@ public abstract class AbstractServerTestBase {
this(URIScheme.HTTP);
}
protected Http2TestServer server;
protected H2TestServer server;
@Rule
public ExternalResource serverResource = new ExternalResource() {
@Override
protected void before() throws Throwable {
server = new Http2TestServer(
server = new H2TestServer(
IOReactorConfig.custom()
.setSoTimeout(TIMEOUT)
.build(),

View File

@ -45,7 +45,7 @@ import org.apache.hc.core5.http.HeaderElements;
import org.apache.hc.core5.http.HttpHeaders;
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.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Rule;
@ -114,7 +114,7 @@ public class TestHttp1Async extends AbstractHttpAsyncFundamentalsTest<CloseableH
@Override
public HttpHost start() throws Exception {
return super.start(null, H1Config.DEFAULT);
return super.start(null, Http1Config.DEFAULT);
}
@Test

View File

@ -48,7 +48,7 @@ import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus;
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.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
@ -105,7 +105,7 @@ public class TestHttp1AsyncStatefulConnManagement extends AbstractIntegrationTes
@Override
public HttpHost start() throws Exception {
return super.start(null, H1Config.DEFAULT);
return super.start(null, Http1Config.DEFAULT);
}
@Test

View File

@ -54,7 +54,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.impl.HttpProcessors;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
@ -159,7 +159,7 @@ public class TestHttp1ClientAuthentication extends AbstractHttpAsyncClientAuthen
}
},
H1Config.DEFAULT);
Http1Config.DEFAULT);
final TestCredentialsProvider credsProvider = new TestCredentialsProvider(
new UsernamePasswordCredentials("test", "test".toCharArray()));

View File

@ -48,10 +48,10 @@ import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.Message;
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.AsyncClientEndpoint;
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.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.http2.config.H2Config;
import org.apache.hc.core5.reactor.IOReactorConfig;
@ -91,10 +91,10 @@ public class TestHttpAsyncMinimal extends AbstractHttpAsyncFundamentalsTest<Mini
.build();
if (version.greaterEquals(HttpVersion.HTTP_2)) {
return HttpAsyncClients.createMinimal(
HttpVersionPolicy.FORCE_HTTP_2, H2Config.DEFAULT, H1Config.DEFAULT, ioReactorConfig, connectionManager);
HttpVersionPolicy.FORCE_HTTP_2, H2Config.DEFAULT, Http1Config.DEFAULT, ioReactorConfig, connectionManager);
} else {
return HttpAsyncClients.createMinimal(
HttpVersionPolicy.FORCE_HTTP_1, H2Config.DEFAULT, H1Config.DEFAULT, ioReactorConfig, connectionManager);
HttpVersionPolicy.FORCE_HTTP_1, H2Config.DEFAULT, Http1Config.DEFAULT, ioReactorConfig, connectionManager);
}
}
@ -103,7 +103,7 @@ public class TestHttpAsyncMinimal extends AbstractHttpAsyncFundamentalsTest<Mini
if (version.greaterEquals(HttpVersion.HTTP_2)) {
return super.start(null, H2Config.DEFAULT);
} else {
return super.start(null, H1Config.DEFAULT);
return super.start(null, Http1Config.DEFAULT);
}
}

View File

@ -38,7 +38,7 @@ import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.config.Http1Config;
import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
import org.apache.hc.core5.http.impl.io.DefaultBHttpServerConnection;
@ -54,7 +54,7 @@ public class TestMalformedServerResponse {
static class BrokenServerConnection extends DefaultBHttpServerConnection {
public BrokenServerConnection(final H1Config h1Config) {
public BrokenServerConnection(final Http1Config h1Config) {
super(null, h1Config);
}
@ -81,7 +81,7 @@ public class TestMalformedServerResponse {
@Override
public DefaultBHttpServerConnection createConnection(final Socket socket) throws IOException {
final BrokenServerConnection conn = new BrokenServerConnection(H1Config.DEFAULT);
final BrokenServerConnection conn = new BrokenServerConnection(Http1Config.DEFAULT);
conn.bind(socket);
return conn;
}

View File

@ -39,7 +39,7 @@ import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
@ -49,9 +49,9 @@ import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.client5.http.ssl.TrustAllStrategy;
import org.apache.hc.client5.http.ssl.TrustSelfSignedStrategy;
import org.apache.hc.client5.testing.SSLTestContexts;
import org.apache.hc.core5.function.Callback;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
import org.apache.hc.core5.http.impl.bootstrap.SSLServerSetupHandler;
import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
@ -190,11 +190,11 @@ public class TestSSLSocketFactory {
// @formatter:off
this.server = ServerBootstrap.bootstrap()
.setSslContext(SSLTestContexts.createServerSSLContext())
.setSslSetupHandler(new SSLServerSetupHandler() {
.setSslSetupHandler(new Callback<SSLParameters>() {
@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<SSLParameters>() {
@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<SSLParameters>() {
@Override
public void initialize(final SSLServerSocket socket) {
socket.setEnabledCipherSuites(new String[] {cipherSuite});
public void execute(final SSLParameters sslParameters) {
sslParameters.setProtocols(new String[] {cipherSuite});
}
})

View File

@ -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;

View File

@ -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;
/**

View File

@ -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 <? extends NameValuePair> 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<? extends NameValuePair> 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
*

View File

@ -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<ExceptionEvent> getExceptionLog() {
return ioReactor.getExceptionLog();
}
@Override
public final void awaitShutdown(final TimeValue waitTime) throws InterruptedException {
ioReactor.awaitShutdown(waitTime);

View File

@ -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<ExceptionEvent> getExceptionLog();
public abstract void awaitShutdown(TimeValue waitTime) throws InterruptedException;
public abstract void initiateShutdown();

View File

@ -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<IOSession>() {

View File

@ -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);
}
}

View File

@ -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<IOSession>() {

View File

@ -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<AsyncPushConsumer> 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<HttpResponse> http1ResponseParserFactory;
@ -89,14 +89,14 @@ class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory {
final HandlerFactory<AsyncPushConsumer> 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,

View File

@ -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);
}

View File

@ -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
* <http://www.apache.org/>.
*
*/
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<Exception> {
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);
}
}

View File

@ -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();

View File

@ -106,6 +106,7 @@ public final class MinimalHttp2AsyncClient extends AbstractMinimalHttpAsyncClien
reactorConfig,
workerThreadFactory,
null,
LoggingExceptionCallback.INSTANCE,
null,
new Callback<IOSession>() {

View File

@ -116,6 +116,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
reactorConfig,
workerThreadFactory,
null,
LoggingExceptionCallback.INSTANCE,
null,
new Callback<IOSession>() {

View File

@ -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<ManagedHttpClientConnection> connFactory,
final H1Config h1Config,
final Http1Config h1Config,
final CharCodingConfig charCodingConfig,
final RequestConfig requestConfig) {
super();

View File

@ -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<ClassicHttpResponse> create(final H1Config h1Config) {
public HttpMessageParser<ClassicHttpResponse> create(final Http1Config h1Config) {
return new LenientHttpResponseParser(this.lineParser, this.responseFactory, h1Config);
}

View File

@ -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<ClassicHttpRequest> requestWriterFactory,

View File

@ -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<ClassicHttpResponse> 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);
}

View File

@ -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<ClassicHttpRequest> requestWriterFactory;
private final HttpMessageParserFactory<ClassicHttpResponse> 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<ClassicHttpRequest> requestWriterFactory,
final HttpMessageParserFactory<ClassicHttpResponse> 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<ClassicHttpRequest> requestWriterFactory,
final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
@ -96,7 +96,7 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
}
public ManagedHttpClientConnectionFactory(
final H1Config h1Config,
final Http1Config h1Config,
final CharCodingConfig charCodingConfig,
final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
this(h1Config, charCodingConfig, null, responseParserFactory);

View File

@ -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) {

View File

@ -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<String> 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<String> 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()) {

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -146,11 +146,6 @@ public class AsyncClientHttp2ServerPush {
System.out.println(requestURI + "->" + cause);
}
@Override
public Void getResult() {
return null;
}
@Override
public void releaseResources() {
}

View File

@ -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);

View File

@ -115,11 +115,6 @@ public class AsyncQuickStart {
return response;
}
@Override
public HttpResponse getResult() {
return response;
}
@Override
public void releaseResources() {
}

View File

@ -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<ClassicHttpResponse> responseParserFactory = new DefaultHttpResponseParserFactory() {
@Override
public HttpMessageParser<ClassicHttpResponse> create(final H1Config h1Config) {
public HttpMessageParser<ClassicHttpResponse> create(final Http1Config h1Config) {
final LineParser lineParser = new BasicLineParser() {
@Override
@ -118,7 +118,7 @@ public class ClientConfiguration {
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory = new DefaultHttpRequestWriterFactory();
// Create HTTP/1.1 protocol configuration
final H1Config h1Config = H1Config.custom()
final Http1Config h1Config = Http1Config.custom()
.setMaxHeaderCount(200)
.setMaxLineLength(2000)
.build();

View File

@ -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();

View File

@ -67,7 +67,7 @@
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<httpcore.version>5.0-beta7</httpcore.version>
<httpcore.version>5.0-beta8</httpcore.version>
<log4j.version>2.9.1</log4j.version>
<commons-codec.version>1.12</commons-codec.version>
<conscrypt.version>1.4.1</conscrypt.version>