Upgraded HttpCore to version 5.2-beta1
This commit is contained in:
parent
5f9bc347ee
commit
a3bbcc82ae
|
@ -765,7 +765,7 @@ public class H2AsyncClientBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();
|
final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();
|
||||||
final IOEventHandlerFactory ioEventHandlerFactory = new H2AsyncClientEventHandlerFactory(
|
final IOEventHandlerFactory ioEventHandlerFactory = new H2AsyncClientProtocolStarter(
|
||||||
new DefaultHttpProcessor(new H2RequestContent(), new H2RequestTargetHost(), new H2RequestConnControl()),
|
new DefaultHttpProcessor(new H2RequestContent(), new H2RequestTargetHost(), new H2RequestConnControl()),
|
||||||
(request, context) -> pushConsumerRegistry.get(request),
|
(request, context) -> pushConsumerRegistry.get(request),
|
||||||
h2Config != null ? h2Config : H2Config.DEFAULT,
|
h2Config != null ? h2Config : H2Config.DEFAULT,
|
||||||
|
|
|
@ -39,8 +39,8 @@ import org.apache.hc.core5.http.protocol.HttpProcessor;
|
||||||
import org.apache.hc.core5.http2.config.H2Config;
|
import org.apache.hc.core5.http2.config.H2Config;
|
||||||
import org.apache.hc.core5.http2.frame.FramePrinter;
|
import org.apache.hc.core5.http2.frame.FramePrinter;
|
||||||
import org.apache.hc.core5.http2.frame.RawFrame;
|
import org.apache.hc.core5.http2.frame.RawFrame;
|
||||||
|
import org.apache.hc.core5.http2.impl.nio.ClientH2PrefaceHandler;
|
||||||
import org.apache.hc.core5.http2.impl.nio.ClientH2StreamMultiplexerFactory;
|
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.http2.impl.nio.H2StreamListener;
|
||||||
import org.apache.hc.core5.reactor.IOEventHandler;
|
import org.apache.hc.core5.reactor.IOEventHandler;
|
||||||
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
||||||
|
@ -49,7 +49,7 @@ import org.apache.hc.core5.util.Args;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
class H2AsyncClientEventHandlerFactory implements IOEventHandlerFactory {
|
class H2AsyncClientProtocolStarter implements IOEventHandlerFactory {
|
||||||
|
|
||||||
private static final Logger HEADER_LOG = LoggerFactory.getLogger("org.apache.hc.client5.http.headers");
|
private static final Logger HEADER_LOG = LoggerFactory.getLogger("org.apache.hc.client5.http.headers");
|
||||||
private static final Logger FRAME_LOG = LoggerFactory.getLogger("org.apache.hc.client5.http2.frame");
|
private static final Logger FRAME_LOG = LoggerFactory.getLogger("org.apache.hc.client5.http2.frame");
|
||||||
|
@ -61,7 +61,7 @@ class H2AsyncClientEventHandlerFactory implements IOEventHandlerFactory {
|
||||||
private final H2Config h2Config;
|
private final H2Config h2Config;
|
||||||
private final CharCodingConfig charCodingConfig;
|
private final CharCodingConfig charCodingConfig;
|
||||||
|
|
||||||
H2AsyncClientEventHandlerFactory(
|
H2AsyncClientProtocolStarter(
|
||||||
final HttpProcessor httpProcessor,
|
final HttpProcessor httpProcessor,
|
||||||
final HandlerFactory<AsyncPushConsumer> exchangeHandlerFactory,
|
final HandlerFactory<AsyncPushConsumer> exchangeHandlerFactory,
|
||||||
final H2Config h2Config,
|
final H2Config h2Config,
|
||||||
|
@ -163,7 +163,7 @@ class H2AsyncClientEventHandlerFactory implements IOEventHandlerFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
return new H2OnlyClientProtocolNegotiator(ioSession, http2StreamHandlerFactory, false);
|
return new ClientH2PrefaceHandler(ioSession, http2StreamHandlerFactory, false);
|
||||||
}
|
}
|
||||||
final ClientH2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientH2StreamMultiplexerFactory(
|
final ClientH2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientH2StreamMultiplexerFactory(
|
||||||
httpProcessor,
|
httpProcessor,
|
||||||
|
@ -171,7 +171,7 @@ class H2AsyncClientEventHandlerFactory implements IOEventHandlerFactory {
|
||||||
h2Config,
|
h2Config,
|
||||||
charCodingConfig,
|
charCodingConfig,
|
||||||
null);
|
null);
|
||||||
return new H2OnlyClientProtocolNegotiator(ioSession, http2StreamHandlerFactory, false);
|
return new ClientH2PrefaceHandler(ioSession, http2StreamHandlerFactory, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -933,7 +933,7 @@ public class HttpAsyncClientBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();
|
final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();
|
||||||
final IOEventHandlerFactory ioEventHandlerFactory = new HttpAsyncClientEventHandlerFactory(
|
final IOEventHandlerFactory ioEventHandlerFactory = new HttpAsyncClientProtocolNegotiationStarter(
|
||||||
new DefaultHttpProcessor(new H2RequestContent(), new H2RequestTargetHost(), new H2RequestConnControl()),
|
new DefaultHttpProcessor(new H2RequestContent(), new H2RequestTargetHost(), new H2RequestConnControl()),
|
||||||
(request, context) -> pushConsumerRegistry.get(request),
|
(request, context) -> pushConsumerRegistry.get(request),
|
||||||
h2Config != null ? h2Config : H2Config.DEFAULT,
|
h2Config != null ? h2Config : H2Config.DEFAULT,
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.apache.hc.core5.http.HttpResponse;
|
||||||
import org.apache.hc.core5.http.config.CharCodingConfig;
|
import org.apache.hc.core5.http.config.CharCodingConfig;
|
||||||
import org.apache.hc.core5.http.config.Http1Config;
|
import org.apache.hc.core5.http.config.Http1Config;
|
||||||
import org.apache.hc.core5.http.impl.Http1StreamListener;
|
import org.apache.hc.core5.http.impl.Http1StreamListener;
|
||||||
|
import org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler;
|
||||||
import org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexerFactory;
|
import org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexerFactory;
|
||||||
import org.apache.hc.core5.http.impl.nio.DefaultHttpRequestWriterFactory;
|
import org.apache.hc.core5.http.impl.nio.DefaultHttpRequestWriterFactory;
|
||||||
import org.apache.hc.core5.http.impl.nio.DefaultHttpResponseParserFactory;
|
import org.apache.hc.core5.http.impl.nio.DefaultHttpResponseParserFactory;
|
||||||
|
@ -54,9 +55,13 @@ import org.apache.hc.core5.http2.HttpVersionPolicy;
|
||||||
import org.apache.hc.core5.http2.config.H2Config;
|
import org.apache.hc.core5.http2.config.H2Config;
|
||||||
import org.apache.hc.core5.http2.frame.FramePrinter;
|
import org.apache.hc.core5.http2.frame.FramePrinter;
|
||||||
import org.apache.hc.core5.http2.frame.RawFrame;
|
import org.apache.hc.core5.http2.frame.RawFrame;
|
||||||
|
import org.apache.hc.core5.http2.impl.nio.ClientH2PrefaceHandler;
|
||||||
import org.apache.hc.core5.http2.impl.nio.ClientH2StreamMultiplexerFactory;
|
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.ClientH2UpgradeHandler;
|
||||||
|
import org.apache.hc.core5.http2.impl.nio.ClientHttp1UpgradeHandler;
|
||||||
import org.apache.hc.core5.http2.impl.nio.H2StreamListener;
|
import org.apache.hc.core5.http2.impl.nio.H2StreamListener;
|
||||||
|
import org.apache.hc.core5.http2.impl.nio.HttpProtocolNegotiator;
|
||||||
|
import org.apache.hc.core5.http2.ssl.ApplicationProtocol;
|
||||||
import org.apache.hc.core5.reactor.IOEventHandler;
|
import org.apache.hc.core5.reactor.IOEventHandler;
|
||||||
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
|
||||||
import org.apache.hc.core5.reactor.ProtocolIOSession;
|
import org.apache.hc.core5.reactor.ProtocolIOSession;
|
||||||
|
@ -64,7 +69,7 @@ import org.apache.hc.core5.util.Args;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory {
|
class HttpAsyncClientProtocolNegotiationStarter implements IOEventHandlerFactory {
|
||||||
|
|
||||||
private static final Logger STREAM_LOG = LoggerFactory.getLogger(InternalHttpAsyncClient.class);
|
private static final Logger STREAM_LOG = LoggerFactory.getLogger(InternalHttpAsyncClient.class);
|
||||||
private static final Logger HEADER_LOG = LoggerFactory.getLogger("org.apache.hc.client5.http.headers");
|
private static final Logger HEADER_LOG = LoggerFactory.getLogger("org.apache.hc.client5.http.headers");
|
||||||
|
@ -81,7 +86,7 @@ class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory {
|
||||||
private final NHttpMessageParserFactory<HttpResponse> http1ResponseParserFactory;
|
private final NHttpMessageParserFactory<HttpResponse> http1ResponseParserFactory;
|
||||||
private final NHttpMessageWriterFactory<HttpRequest> http1RequestWriterFactory;
|
private final NHttpMessageWriterFactory<HttpRequest> http1RequestWriterFactory;
|
||||||
|
|
||||||
HttpAsyncClientEventHandlerFactory(
|
HttpAsyncClientProtocolNegotiationStarter(
|
||||||
final HttpProcessor httpProcessor,
|
final HttpProcessor httpProcessor,
|
||||||
final HandlerFactory<AsyncPushConsumer> exchangeHandlerFactory,
|
final HandlerFactory<AsyncPushConsumer> exchangeHandlerFactory,
|
||||||
final H2Config h2Config,
|
final H2Config h2Config,
|
||||||
|
@ -100,13 +105,16 @@ class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IOEventHandler createHandler(final ProtocolIOSession ioSession, final Object attachment) {
|
public IOEventHandler createHandler(final ProtocolIOSession ioSession, final Object attachment) {
|
||||||
|
final ClientHttp1StreamDuplexerFactory http1StreamHandlerFactory;
|
||||||
|
final ClientH2StreamMultiplexerFactory http2StreamHandlerFactory;
|
||||||
|
|
||||||
if (STREAM_LOG.isDebugEnabled()
|
if (STREAM_LOG.isDebugEnabled()
|
||||||
|| HEADER_LOG.isDebugEnabled()
|
|| HEADER_LOG.isDebugEnabled()
|
||||||
|| FRAME_LOG.isDebugEnabled()
|
|| FRAME_LOG.isDebugEnabled()
|
||||||
|| FRAME_PAYLOAD_LOG.isDebugEnabled()
|
|| FRAME_PAYLOAD_LOG.isDebugEnabled()
|
||||||
|| FLOW_CTRL_LOG.isDebugEnabled()) {
|
|| FLOW_CTRL_LOG.isDebugEnabled()) {
|
||||||
final String id = ioSession.getId();
|
final String id = ioSession.getId();
|
||||||
final ClientHttp1StreamDuplexerFactory http1StreamHandlerFactory = new ClientHttp1StreamDuplexerFactory(
|
http1StreamHandlerFactory = new ClientHttp1StreamDuplexerFactory(
|
||||||
httpProcessor,
|
httpProcessor,
|
||||||
h1Config,
|
h1Config,
|
||||||
charCodingConfig,
|
charCodingConfig,
|
||||||
|
@ -147,7 +155,7 @@ class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
final ClientH2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientH2StreamMultiplexerFactory(
|
http2StreamHandlerFactory = new ClientH2StreamMultiplexerFactory(
|
||||||
httpProcessor,
|
httpProcessor,
|
||||||
exchangeHandlerFactory,
|
exchangeHandlerFactory,
|
||||||
h2Config,
|
h2Config,
|
||||||
|
@ -231,13 +239,8 @@ class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
return new ClientHttpProtocolNegotiator(
|
} else {
|
||||||
ioSession,
|
http1StreamHandlerFactory = new ClientHttp1StreamDuplexerFactory(
|
||||||
http1StreamHandlerFactory,
|
|
||||||
http2StreamHandlerFactory,
|
|
||||||
attachment instanceof HttpVersionPolicy ? (HttpVersionPolicy) attachment : null);
|
|
||||||
}
|
|
||||||
final ClientHttp1StreamDuplexerFactory http1StreamHandlerFactory = new ClientHttp1StreamDuplexerFactory(
|
|
||||||
httpProcessor,
|
httpProcessor,
|
||||||
h1Config,
|
h1Config,
|
||||||
charCodingConfig,
|
charCodingConfig,
|
||||||
|
@ -245,17 +248,26 @@ class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory {
|
||||||
http1ResponseParserFactory,
|
http1ResponseParserFactory,
|
||||||
http1RequestWriterFactory,
|
http1RequestWriterFactory,
|
||||||
null);
|
null);
|
||||||
final ClientH2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientH2StreamMultiplexerFactory(
|
http2StreamHandlerFactory = new ClientH2StreamMultiplexerFactory(
|
||||||
httpProcessor,
|
httpProcessor,
|
||||||
exchangeHandlerFactory,
|
exchangeHandlerFactory,
|
||||||
h2Config,
|
h2Config,
|
||||||
charCodingConfig,
|
charCodingConfig,
|
||||||
null);
|
null);
|
||||||
return new ClientHttpProtocolNegotiator(
|
}
|
||||||
ioSession,
|
|
||||||
http1StreamHandlerFactory,
|
ioSession.registerProtocol(ApplicationProtocol.HTTP_1_1.id, new ClientHttp1UpgradeHandler(http1StreamHandlerFactory));
|
||||||
http2StreamHandlerFactory,
|
ioSession.registerProtocol(ApplicationProtocol.HTTP_2.id, new ClientH2UpgradeHandler(http2StreamHandlerFactory));
|
||||||
attachment instanceof HttpVersionPolicy ? (HttpVersionPolicy) attachment : null);
|
|
||||||
|
final HttpVersionPolicy versionPolicy = attachment instanceof HttpVersionPolicy ? (HttpVersionPolicy) attachment : HttpVersionPolicy.NEGOTIATE;
|
||||||
|
switch (versionPolicy) {
|
||||||
|
case FORCE_HTTP_2:
|
||||||
|
return new ClientH2PrefaceHandler(ioSession, http2StreamHandlerFactory, false);
|
||||||
|
case FORCE_HTTP_1:
|
||||||
|
return new ClientHttp1IOEventHandler(http1StreamHandlerFactory.create(ioSession));
|
||||||
|
default:
|
||||||
|
return new HttpProtocolNegotiator(ioSession, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -154,7 +154,7 @@ public final class HttpAsyncClients {
|
||||||
final AsyncClientConnectionManager connmgr) {
|
final AsyncClientConnectionManager connmgr) {
|
||||||
final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();
|
final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();
|
||||||
return createMinimalHttpAsyncClientImpl(
|
return createMinimalHttpAsyncClientImpl(
|
||||||
new HttpAsyncClientEventHandlerFactory(
|
new HttpAsyncClientProtocolNegotiationStarter(
|
||||||
createMinimalProtocolProcessor(),
|
createMinimalProtocolProcessor(),
|
||||||
(request, context) -> pushConsumerRegistry.get(request),
|
(request, context) -> pushConsumerRegistry.get(request),
|
||||||
h2Config,
|
h2Config,
|
||||||
|
@ -182,7 +182,7 @@ public final class HttpAsyncClients {
|
||||||
final AsyncClientConnectionManager connmgr) {
|
final AsyncClientConnectionManager connmgr) {
|
||||||
final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();
|
final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();
|
||||||
return createMinimalHttpAsyncClientImpl(
|
return createMinimalHttpAsyncClientImpl(
|
||||||
new HttpAsyncClientEventHandlerFactory(
|
new HttpAsyncClientProtocolNegotiationStarter(
|
||||||
createMinimalProtocolProcessor(),
|
createMinimalProtocolProcessor(),
|
||||||
(request, context) -> pushConsumerRegistry.get(request),
|
(request, context) -> pushConsumerRegistry.get(request),
|
||||||
h2Config,
|
h2Config,
|
||||||
|
@ -285,7 +285,7 @@ public final class HttpAsyncClients {
|
||||||
final TlsStrategy tlsStrategy) {
|
final TlsStrategy tlsStrategy) {
|
||||||
final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();
|
final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();
|
||||||
return createMinimalHttp2AsyncClientImpl(
|
return createMinimalHttp2AsyncClientImpl(
|
||||||
new H2AsyncClientEventHandlerFactory(
|
new H2AsyncClientProtocolStarter(
|
||||||
createMinimalProtocolProcessor(),
|
createMinimalProtocolProcessor(),
|
||||||
(request, context) -> pushConsumerRegistry.get(request),
|
(request, context) -> pushConsumerRegistry.get(request),
|
||||||
h2Config,
|
h2Config,
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -62,7 +62,7 @@
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<httpcore.version>5.2-alpha2</httpcore.version>
|
<httpcore.version>5.2-beta1</httpcore.version>
|
||||||
<log4j.version>2.17.0</log4j.version>
|
<log4j.version>2.17.0</log4j.version>
|
||||||
<commons-codec.version>1.15</commons-codec.version>
|
<commons-codec.version>1.15</commons-codec.version>
|
||||||
<conscrypt.version>2.5.2</conscrypt.version>
|
<conscrypt.version>2.5.2</conscrypt.version>
|
||||||
|
|
Loading…
Reference in New Issue