Removed protocol upgrade API changes (moved to 5.2)
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2UpgradeHandler.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2UpgradeHandler.java
deleted file mode 100644
index 67fbbe3..0000000
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractH2UpgradeHandler.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * ====================================================================
- * 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.core5.http2.impl.nio;
-
-import java.io.IOException;
-
-import org.apache.hc.core5.concurrent.CallbackContribution;
-import org.apache.hc.core5.concurrent.FutureCallback;
-import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.URIScheme;
-import org.apache.hc.core5.reactor.EndpointParameters;
-import org.apache.hc.core5.http.impl.nio.HttpConnectionEventHandler;
-import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
-import org.apache.hc.core5.http2.HttpVersionPolicy;
-import org.apache.hc.core5.reactor.ProtocolIOSession;
-import org.apache.hc.core5.reactor.ProtocolUpgradeHandler;
-import org.apache.hc.core5.reactor.TransportSecurityLayerEx;
-import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.Timeout;
-
-abstract class AbstractH2UpgradeHandler implements ProtocolUpgradeHandler {
-
- private final TlsStrategy tlsStrategy;
- private final Timeout handshakeTimeout;
-
- AbstractH2UpgradeHandler(final TlsStrategy tlsStrategy, final Timeout handshakeTimeout) {
- this.tlsStrategy = tlsStrategy;
- this.handshakeTimeout = handshakeTimeout;
- }
-
- protected abstract HttpConnectionEventHandler createProtocolNegotiator(ProtocolIOSession ioSession,
- FutureCallback<ProtocolIOSession> callback);
-
- private void negotiateHttp(final ProtocolIOSession ioSession,
- final FutureCallback<ProtocolIOSession> callback) {
- final HttpConnectionEventHandler protocolNegotiator = createProtocolNegotiator(ioSession, callback);
- ioSession.upgrade(protocolNegotiator);
- try {
- protocolNegotiator.connected(ioSession);
- } catch (final IOException ex) {
- protocolNegotiator.exception(ioSession, ex);
- }
- }
-
- @Override
- public final void upgrade(final ProtocolIOSession ioSession,
- final EndpointParameters parameters,
- final FutureCallback<ProtocolIOSession> callback) {
- Args.notNull(parameters, "Endpoint parameters");
- if (URIScheme.HTTPS.same(parameters.getScheme())) {
- if (ioSession instanceof TransportSecurityLayerEx) {
- final TransportSecurityLayerEx transportSecurityLayer = (TransportSecurityLayerEx) ioSession;
- transportSecurityLayer.subscribe(new CallbackContribution<ProtocolIOSession>(callback) {
-
- @Override
- public void completed(final ProtocolIOSession result) {
- negotiateHttp(ioSession, callback);
- }
-
- });
- tlsStrategy.upgrade(
- transportSecurityLayer,
- new HttpHost(parameters.getScheme(), parameters.getHostName(), parameters.getPort()),
- ioSession.getLocalAddress(),
- ioSession.getRemoteAddress(),
- HttpVersionPolicy.FORCE_HTTP_2,
- handshakeTimeout);
- } else {
- throw new UnsupportedOperationException("TLS upgrade not supported");
- }
- } else {
- negotiateHttp(ioSession, callback);
- }
- }
-
-}
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientH2UpgradeHandler.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientH2UpgradeHandler.java
deleted file mode 100644
index 3c26314..0000000
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientH2UpgradeHandler.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * ====================================================================
- * 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.core5.http2.impl.nio;
-
-import org.apache.hc.core5.annotation.Contract;
-import org.apache.hc.core5.annotation.Internal;
-import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.concurrent.FutureCallback;
-import org.apache.hc.core5.http.impl.nio.HttpConnectionEventHandler;
-import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
-import org.apache.hc.core5.reactor.ProtocolIOSession;
-import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.Timeout;
-
-/**
- * Protocol upgrade handler that upgrades the underlying {@link ProtocolIOSession}
- * to HTTP/2 in case of a successful protocol negotiation.
- *
- * @since 5.1
- */
-@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
-@Internal
-public class ClientH2UpgradeHandler extends AbstractH2UpgradeHandler {
-
- private final ClientH2StreamMultiplexerFactory http2StreamHandlerFactory;
-
- public ClientH2UpgradeHandler(
- final ClientH2StreamMultiplexerFactory http2StreamHandlerFactory,
- final TlsStrategy tlsStrategy,
- final Timeout handshakeTimeout) {
- super(tlsStrategy, handshakeTimeout);
- this.http2StreamHandlerFactory = Args.notNull(http2StreamHandlerFactory, "HTTP/2 stream handler factory");
- }
-
- @Override
- protected HttpConnectionEventHandler createProtocolNegotiator(final ProtocolIOSession ioSession,
- final FutureCallback<ProtocolIOSession> callback) {
- return new H2OnlyClientProtocolNegotiator(
- ioSession,
- http2StreamHandlerFactory,
- true,
- callback);
- }
-
-}
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerH2UpgradeHandler.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerH2UpgradeHandler.java
deleted file mode 100644
index ab8bf7c..0000000
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerH2UpgradeHandler.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * ====================================================================
- * 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.core5.http2.impl.nio;
-
-import org.apache.hc.core5.annotation.Contract;
-import org.apache.hc.core5.annotation.Internal;
-import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.concurrent.FutureCallback;
-import org.apache.hc.core5.http.impl.nio.HttpConnectionEventHandler;
-import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
-import org.apache.hc.core5.reactor.ProtocolIOSession;
-import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.Timeout;
-
-/**
- * Protocol upgrade handler that upgrades the underlying {@link ProtocolIOSession}
- * to HTTP/2 in case of a successful protocol negotiation.
- *
- * @since 5.1
- */
-@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
-@Internal
-public class ServerH2UpgradeHandler extends AbstractH2UpgradeHandler {
-
- private final ServerH2StreamMultiplexerFactory http2StreamHandlerFactory;
-
- public ServerH2UpgradeHandler(
- final ServerH2StreamMultiplexerFactory http2StreamHandlerFactory,
- final TlsStrategy tlsStrategy,
- final Timeout handshakeTimeout) {
- super(tlsStrategy, handshakeTimeout);
- this.http2StreamHandlerFactory = Args.notNull(http2StreamHandlerFactory, "HTTP/2 stream handler factory");
- }
-
- @Override
- protected HttpConnectionEventHandler createProtocolNegotiator(final ProtocolIOSession ioSession,
- final FutureCallback<ProtocolIOSession> callback) {
- return new H2OnlyServerHttpProtocolNegotiator(
- ioSession,
- http2StreamHandlerFactory,
- callback);
- }
-
-}
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2AsyncRequester.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2AsyncRequester.java
index e7642b6..de22471 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2AsyncRequester.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2AsyncRequester.java
@@ -34,7 +34,6 @@
import org.apache.hc.core5.function.Callback;
import org.apache.hc.core5.function.Decorator;
import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.impl.bootstrap.HttpAsyncRequester;
import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
import org.apache.hc.core5.http2.HttpVersionPolicy;
@@ -43,7 +42,6 @@
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.reactor.IOSession;
import org.apache.hc.core5.reactor.IOSessionListener;
-import org.apache.hc.core5.reactor.ProtocolUpgradeHandler;
import org.apache.hc.core5.util.Timeout;
/**
@@ -72,26 +70,6 @@
this.versionPolicy = versionPolicy != null ? versionPolicy : HttpVersionPolicy.NEGOTIATE;
}
- /**
- * Use {@link H2RequesterBootstrap} to create instances of this class.
- *
- * @since 5.1
- */
- @Internal
- public H2AsyncRequester(
- final HttpVersionPolicy versionPolicy,
- final IOReactorConfig ioReactorConfig,
- final IOEventHandlerFactory eventHandlerFactory,
- final Decorator<IOSession> ioSessionDecorator,
- final Callback<Exception> exceptionCallback,
- final IOSessionListener sessionListener,
- final ManagedConnPool<HttpHost, IOSession> connPool,
- final Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup) {
- super(ioReactorConfig, eventHandlerFactory, ioSessionDecorator, exceptionCallback, sessionListener, connPool,
- protocolUpgradeHandlerLookup);
- this.versionPolicy = versionPolicy != null ? versionPolicy : HttpVersionPolicy.NEGOTIATE;
- }
-
@Override
protected Future<AsyncClientEndpoint> doConnect(
final HttpHost host,
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java
index 76be6fc..44adb0d 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java
@@ -36,8 +36,6 @@
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.config.CharCodingConfig;
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.DefaultConnectionReuseStrategy;
import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
import org.apache.hc.core5.http.impl.Http1StreamListener;
@@ -54,12 +52,10 @@
import org.apache.hc.core5.http2.config.H2Config;
import org.apache.hc.core5.http2.impl.H2Processors;
import org.apache.hc.core5.http2.impl.nio.ClientH2StreamMultiplexerFactory;
-import org.apache.hc.core5.http2.impl.nio.ClientH2UpgradeHandler;
import org.apache.hc.core5.http2.impl.nio.ClientHttpProtocolNegotiatorFactory;
import org.apache.hc.core5.http2.impl.nio.H2StreamListener;
import org.apache.hc.core5.http2.nio.support.DefaultAsyncPushConsumerFactory;
import org.apache.hc.core5.http2.ssl.H2ClientTlsStrategy;
-import org.apache.hc.core5.http2.ssl.TlsUpgradeHandler;
import org.apache.hc.core5.pool.ConnPoolListener;
import org.apache.hc.core5.pool.DefaultDisposalCallback;
import org.apache.hc.core5.pool.LaxConnPool;
@@ -71,7 +67,6 @@
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.reactor.IOSession;
import org.apache.hc.core5.reactor.IOSessionListener;
-import org.apache.hc.core5.reactor.ProtocolUpgradeHandler;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.TimeValue;
import org.apache.hc.core5.util.Timeout;
@@ -329,11 +324,6 @@
final HttpVersionPolicy actualVersionProtocol = versionPolicy != null ? versionPolicy : HttpVersionPolicy.NEGOTIATE;
final TlsStrategy actualTlsStrategy = tlsStrategy != null ? tlsStrategy : new H2ClientTlsStrategy();
- final Registry<ProtocolUpgradeHandler> protocolRegistry = RegistryBuilder.<ProtocolUpgradeHandler>create()
- .register("TLS", new TlsUpgradeHandler(actualVersionProtocol, actualTlsStrategy, handshakeTimeout))
- .register("H2", new ClientH2UpgradeHandler(http2StreamHandlerFactory, actualTlsStrategy, handshakeTimeout))
- .build();
-
final ClientHttp1StreamDuplexerFactory http1StreamHandlerFactory = new ClientHttp1StreamDuplexerFactory(
httpProcessor != null ? httpProcessor : HttpProcessors.client(),
http1Config != null ? http1Config : Http1Config.DEFAULT,
@@ -343,7 +333,6 @@
DefaultHttpRequestWriterFactory.INSTANCE,
DefaultContentLengthStrategy.INSTANCE,
DefaultContentLengthStrategy.INSTANCE,
- protocolRegistry,
http1StreamListener);
final IOEventHandlerFactory ioEventHandlerFactory = new ClientHttpProtocolNegotiatorFactory(
@@ -360,8 +349,7 @@
ioSessionDecorator,
exceptionCallback,
sessionListener,
- connPool,
- protocolRegistry);
+ connPool);
}
}
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java
index c84c75b..0e71a3b 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2ServerBootstrap.java
@@ -35,8 +35,6 @@
import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.Http1Config;
import org.apache.hc.core5.http.config.NamedElementChain;
-import org.apache.hc.core5.http.config.Registry;
-import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
import org.apache.hc.core5.http.impl.Http1StreamListener;
@@ -67,16 +65,13 @@
import org.apache.hc.core5.http2.impl.H2Processors;
import org.apache.hc.core5.http2.impl.nio.H2StreamListener;
import org.apache.hc.core5.http2.impl.nio.ServerH2StreamMultiplexerFactory;
-import org.apache.hc.core5.http2.impl.nio.ServerH2UpgradeHandler;
import org.apache.hc.core5.http2.impl.nio.ServerHttpProtocolNegotiatorFactory;
import org.apache.hc.core5.http2.ssl.H2ServerTlsStrategy;
-import org.apache.hc.core5.http2.ssl.TlsUpgradeHandler;
import org.apache.hc.core5.net.InetAddressUtils;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.reactor.IOSession;
import org.apache.hc.core5.reactor.IOSessionListener;
-import org.apache.hc.core5.reactor.ProtocolUpgradeHandler;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.Timeout;
@@ -435,11 +430,6 @@
final HttpVersionPolicy actualVersionProtocol = versionPolicy != null ? versionPolicy : HttpVersionPolicy.NEGOTIATE;
final TlsStrategy actualTlsStrategy = tlsStrategy != null ? tlsStrategy : new H2ServerTlsStrategy();
- final Registry<ProtocolUpgradeHandler> protocolRegistry = RegistryBuilder.<ProtocolUpgradeHandler>create()
- .register("TLS", new TlsUpgradeHandler(actualVersionProtocol, actualTlsStrategy, handshakeTimeout))
- .register("H2", new ServerH2UpgradeHandler(http2StreamHandlerFactory, actualTlsStrategy, handshakeTimeout))
- .build();
-
final ServerHttp1StreamDuplexerFactory http1StreamHandlerFactory = new ServerHttp1StreamDuplexerFactory(
httpProcessor != null ? httpProcessor : HttpProcessors.server(),
handlerFactory,
@@ -450,7 +440,6 @@
DefaultHttpResponseWriterFactory.INSTANCE,
DefaultContentLengthStrategy.INSTANCE,
DefaultContentLengthStrategy.INSTANCE,
- protocolRegistry,
http1StreamListener);
final IOEventHandlerFactory ioEventHandlerFactory = new ServerHttpProtocolNegotiatorFactory(
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/TlsUpgradeHandler.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/TlsUpgradeHandler.java
deleted file mode 100644
index 9aadd31..0000000
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/TlsUpgradeHandler.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ====================================================================
- * 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.core5.http2.ssl;
-
-import org.apache.hc.core5.annotation.Contract;
-import org.apache.hc.core5.annotation.Internal;
-import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.concurrent.FutureCallback;
-import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.reactor.EndpointParameters;
-import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
-import org.apache.hc.core5.http2.HttpVersionPolicy;
-import org.apache.hc.core5.reactor.ProtocolIOSession;
-import org.apache.hc.core5.reactor.ProtocolUpgradeHandler;
-import org.apache.hc.core5.reactor.TransportSecurityLayerEx;
-import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.Timeout;
-
-/**
- * Protocol upgrade handler that upgrades the underlying {@link ProtocolIOSession} to TLS
- * using {@link TlsStrategy}.
- *
- * @since 5.1
- */
-@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
-@Internal
-public class TlsUpgradeHandler implements ProtocolUpgradeHandler {
-
- private final HttpVersionPolicy versionPolicy;
- private final TlsStrategy tlsStrategy;
- private final Timeout handshakeTimeout;
-
- public TlsUpgradeHandler(
- final HttpVersionPolicy versionPolicy,
- final TlsStrategy tlsStrategy,
- final Timeout handshakeTimeout) {
- this.versionPolicy = versionPolicy != null ? versionPolicy : HttpVersionPolicy.NEGOTIATE;
- this.tlsStrategy = tlsStrategy;
- this.handshakeTimeout = handshakeTimeout;
- }
-
- @Override
- public void upgrade(final ProtocolIOSession ioSession,
- final EndpointParameters parameters,
- final FutureCallback<ProtocolIOSession> callback) {
- Args.notNull(parameters, "Endpoint parameters");
- if (ioSession instanceof TransportSecurityLayerEx) {
- final TransportSecurityLayerEx transportSecurityLayer = (TransportSecurityLayerEx) ioSession;
- if (callback != null) {
- transportSecurityLayer.subscribe(callback);
- }
- tlsStrategy.upgrade(
- transportSecurityLayer,
- new HttpHost(parameters.getScheme(), parameters.getHostName(), parameters.getPort()),
- ioSession.getLocalAddress(),
- ioSession.getRemoteAddress(),
- versionPolicy,
- handshakeTimeout);
- } else {
- throw new UnsupportedOperationException("TLS upgrade not supported");
- }
- }
-
-}
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/H2ViaHttp1ProxyExecutionExample.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/H2ViaHttp1ProxyExecutionExample.java
deleted file mode 100644
index cd13e34..0000000
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/H2ViaHttp1ProxyExecutionExample.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * ====================================================================
- * 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.core5.http2.examples;
-
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.hc.core5.concurrent.ComplexFuture;
-import org.apache.hc.core5.concurrent.FutureCallback;
-import org.apache.hc.core5.concurrent.FutureContribution;
-import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.HttpConnection;
-import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.HttpStatus;
-import org.apache.hc.core5.http.Message;
-import org.apache.hc.core5.http.Method;
-import org.apache.hc.core5.http.impl.Http1StreamListener;
-import org.apache.hc.core5.http.impl.bootstrap.HttpAsyncRequester;
-import org.apache.hc.core5.reactor.EndpointParameters;
-import org.apache.hc.core5.http.message.BasicHttpRequest;
-import org.apache.hc.core5.http.message.RequestLine;
-import org.apache.hc.core5.http.message.StatusLine;
-import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
-import org.apache.hc.core5.http.nio.entity.NoopEntityConsumer;
-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.http2.HttpVersionPolicy;
-import org.apache.hc.core5.http2.config.H2Config;
-import org.apache.hc.core5.http2.frame.RawFrame;
-import org.apache.hc.core5.http2.impl.nio.H2StreamListener;
-import org.apache.hc.core5.http2.impl.nio.bootstrap.H2RequesterBootstrap;
-import org.apache.hc.core5.io.CloseMode;
-import org.apache.hc.core5.reactor.ProtocolLayer;
-import org.apache.hc.core5.util.Timeout;
-
-/**
- * Example of asynchronous HTTP/2 request execution via a HTTP/1.1 proxy.
- */
-public class H2ViaHttp1ProxyExecutionExample {
-
- public static void main(final String[] args) throws Exception {
-
- // Create and start requester
- final H2Config h2Config = H2Config.custom()
- .setPushEnabled(false)
- .build();
-
- final HttpAsyncRequester requester = H2RequesterBootstrap.bootstrap()
- .setH2Config(h2Config)
- .setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
- .setStreamListener(new Http1StreamListener() {
-
- @Override
- public void onRequestHead(final HttpConnection connection, final HttpRequest request) {
- System.out.println(connection.getRemoteAddress() + " " + new RequestLine(request));
- }
-
- @Override
- public void onResponseHead(final HttpConnection connection, final HttpResponse response) {
- System.out.println(connection.getRemoteAddress() + " " + new StatusLine(response));
- }
-
- @Override
- public void onExchangeComplete(final HttpConnection connection, final boolean keepAlive) {
- if (keepAlive) {
- System.out.println(connection.getRemoteAddress() + " exchange completed (connection kept alive)");
- } else {
- System.out.println(connection.getRemoteAddress() + " exchange completed (connection closed)");
- }
- }
-
- })
- .setStreamListener(new H2StreamListener() {
-
- @Override
- public void onHeaderInput(final HttpConnection connection, final int streamId, final List<? extends Header> headers) {
- for (int i = 0; i < headers.size(); i++) {
- System.out.println(connection.getRemoteAddress() + " (" + streamId + ") << " + headers.get(i));
- }
- }
-
- @Override
- public void onHeaderOutput(final HttpConnection connection, final int streamId, final List<? extends Header> headers) {
- for (int i = 0; i < headers.size(); i++) {
- System.out.println(connection.getRemoteAddress() + " (" + streamId + ") >> " + headers.get(i));
- }
- }
-
- @Override
- public void onFrameInput(final HttpConnection connection, final int streamId, final RawFrame frame) {
- }
-
- @Override
- public void onFrameOutput(final HttpConnection connection, final int streamId, final RawFrame frame) {
- }
-
- @Override
- public void onInputFlowControl(final HttpConnection connection, final int streamId, final int delta, final int actualSize) {
- }
-
- @Override
- public void onOutputFlowControl(final HttpConnection connection, final int streamId, final int delta, final int actualSize) {
- }
-
- })
- .create();
-
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- System.out.println("HTTP requester shutting down");
- requester.close(CloseMode.GRACEFUL);
- }
- });
- requester.start();
-
- final HttpHost proxy = new HttpHost("localhost", 8888);
- final HttpHost target = new HttpHost("https", "nghttp2.org");
-
- final ComplexFuture<AsyncClientEndpoint> tunnelFuture = new ComplexFuture<>(null);
- tunnelFuture.setDependency(requester.connect(
- proxy,
- Timeout.ofSeconds(30),
- null,
- new FutureContribution<AsyncClientEndpoint>(tunnelFuture) {
-
- @Override
- public void completed(final AsyncClientEndpoint endpoint) {
- final HttpRequest connect = new BasicHttpRequest(Method.CONNECT, proxy, target.toHostString());
- endpoint.execute(
- new BasicRequestProducer(connect, null),
- new BasicResponseConsumer<>(new NoopEntityConsumer()),
- new FutureContribution<Message<HttpResponse, Void>>(tunnelFuture) {
-
- @Override
- public void completed(final Message<HttpResponse, Void> message) {
- final HttpResponse response = message.getHead();
- if (response.getCode() == HttpStatus.SC_OK) {
- if (endpoint instanceof ProtocolLayer) {
- final EndpointParameters params = new EndpointParameters(
- target.getSchemeName(),
- target.getHostName(),
- target.getPort(),
- HttpVersionPolicy.NEGOTIATE);
- final ProtocolLayer protocolLayer = (ProtocolLayer) endpoint;
- try {
- protocolLayer.upgrade("H2", params);
- } catch (final RuntimeException ex) {
- tunnelFuture.failed(ex);
- }
- }
- System.out.println("Tunnel to " + target + " via " + proxy + " established");
- tunnelFuture.completed(endpoint);
- } else {
- tunnelFuture.failed(new HttpException("Tunnel refused: " + new StatusLine(response)));
- }
- }
-
- });
- }
-
- }));
-
- final String[] requestUris = new String[] {"/httpbin/ip", "/httpbin/user-agent", "/httpbin/headers"};
- final AsyncClientEndpoint endpoint = tunnelFuture.get(1, TimeUnit.MINUTES);
- try {
- final CountDownLatch latch = new CountDownLatch(requestUris.length);
- for (final String requestUri : requestUris) {
- endpoint.execute(
- new BasicRequestProducer(Method.GET, target, requestUri),
- new BasicResponseConsumer<>(new StringAsyncEntityConsumer()),
- new FutureCallback<Message<HttpResponse, String>>() {
-
- @Override
- public void completed(final Message<HttpResponse, String> message) {
- final HttpResponse response = message.getHead();
- final String body = message.getBody();
- System.out.println(requestUri + "->" + response.getCode());
- System.out.println(body);
- latch.countDown();
- }
-
- @Override
- public void failed(final Exception ex) {
- System.out.println(requestUri + "->" + ex);
- latch.countDown();
- }
-
- @Override
- public void cancelled() {
- System.out.println(requestUri + " cancelled");
- latch.countDown();
- }
-
- });
- }
-
- latch.await();
- } finally {
- endpoint.releaseAndDiscard();
- }
-
- System.out.println("Shutting down I/O reactor");
- requester.initiateShutdown();
- }
-
-}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java
index 5260da7..32f8807 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java
@@ -50,9 +50,7 @@
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.ProtocolException;
-import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.impl.DefaultAddressResolver;
-import org.apache.hc.core5.reactor.EndpointParameters;
import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
@@ -74,14 +72,12 @@
import org.apache.hc.core5.pool.PoolEntry;
import org.apache.hc.core5.pool.PoolStats;
import org.apache.hc.core5.reactor.Command;
+import org.apache.hc.core5.reactor.EndpointParameters;
import org.apache.hc.core5.reactor.IOEventHandler;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.reactor.IOSession;
import org.apache.hc.core5.reactor.IOSessionListener;
-import org.apache.hc.core5.reactor.ProtocolIOSession;
-import org.apache.hc.core5.reactor.ProtocolLayer;
-import org.apache.hc.core5.reactor.ProtocolUpgradeHandler;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.TimeValue;
import org.apache.hc.core5.util.Timeout;
@@ -94,27 +90,6 @@
public class HttpAsyncRequester extends AsyncRequester implements ConnPoolControl<HttpHost> {
private final ManagedConnPool<HttpHost, IOSession> connPool;
- private final Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup;
-
- /**
- * Use {@link AsyncRequesterBootstrap} to create instances of this class.
- *
- * @since 5.1
- */
- @Internal
- public HttpAsyncRequester(
- final IOReactorConfig ioReactorConfig,
- final IOEventHandlerFactory eventHandlerFactory,
- final Decorator<IOSession> ioSessionDecorator,
- final Callback<Exception> exceptionCallback,
- final IOSessionListener sessionListener,
- final ManagedConnPool<HttpHost, IOSession> connPool,
- final Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup) {
- super(eventHandlerFactory, ioReactorConfig, ioSessionDecorator, exceptionCallback, sessionListener,
- ShutdownCommand.GRACEFUL_IMMEDIATE_CALLBACK, DefaultAddressResolver.INSTANCE);
- this.connPool = Args.notNull(connPool, "Connection pool");
- this.protocolUpgradeHandlerLookup = protocolUpgradeHandlerLookup;
- }
/**
* Use {@link AsyncRequesterBootstrap} to create instances of this class.
@@ -127,7 +102,9 @@
final Callback<Exception> exceptionCallback,
final IOSessionListener sessionListener,
final ManagedConnPool<HttpHost, IOSession> connPool) {
- this(ioReactorConfig, eventHandlerFactory, ioSessionDecorator, exceptionCallback, sessionListener, connPool, null);
+ super(eventHandlerFactory, ioReactorConfig, ioSessionDecorator, exceptionCallback, sessionListener,
+ ShutdownCommand.GRACEFUL_IMMEDIATE_CALLBACK, DefaultAddressResolver.INSTANCE);
+ this.connPool = Args.notNull(connPool, "Connection pool");
}
@Override
@@ -434,7 +411,7 @@
return execute(requestProducer, responseConsumer, null, timeout, null, callback);
}
- private class InternalAsyncClientEndpoint extends AsyncClientEndpoint implements ProtocolLayer {
+ private class InternalAsyncClientEndpoint extends AsyncClientEndpoint {
final AtomicReference<PoolEntry<HttpHost, IOSession>> poolEntryRef;
@@ -502,32 +479,6 @@
}
}
- @Override
- public void upgrade(final ProtocolUpgradeHandler upgradeHandler, final EndpointParameters parameters) {
- Args.notNull(upgradeHandler, "Protocol upgrade handler");
- Args.notNull(parameters, "Endpoint parameters");
- final IOSession ioSession = getIOSession();
- if (ioSession instanceof ProtocolIOSession) {
- upgradeHandler.upgrade((ProtocolIOSession) ioSession, parameters, null);
- } else {
- throw new UnsupportedOperationException("Protocol upgrade not supported");
- }
- }
-
- @Override
- public void upgrade(final String id, final EndpointParameters parameters) {
- final IOSession ioSession = getIOSession();
- if (ioSession instanceof ProtocolIOSession) {
- final ProtocolUpgradeHandler upgradeHandler = protocolUpgradeHandlerLookup.lookup(id);
- if (upgradeHandler == null) {
- throw new IllegalArgumentException("Unsupported protocol: " + id);
- }
- upgradeHandler.upgrade((ProtocolIOSession) ioSession, parameters, null);
- } else {
- throw new UnsupportedOperationException("Protocol upgrade not supported by the endpoint");
- }
- }
-
}
}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
index bf4d268..35cf169 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
@@ -51,7 +51,6 @@
import org.apache.hc.core5.http.ProtocolVersion;
import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.Http1Config;
-import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.impl.BasicEndpointDetails;
import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
@@ -71,19 +70,16 @@
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.io.SocketTimeoutExceptionFactory;
import org.apache.hc.core5.reactor.Command;
-import org.apache.hc.core5.reactor.EndpointParameters;
import org.apache.hc.core5.reactor.EventMask;
import org.apache.hc.core5.reactor.IOSession;
import org.apache.hc.core5.reactor.ProtocolIOSession;
-import org.apache.hc.core5.reactor.ProtocolLayer;
-import org.apache.hc.core5.reactor.ProtocolUpgradeHandler;
import org.apache.hc.core5.reactor.ssl.TlsDetails;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.Identifiable;
import org.apache.hc.core5.util.Timeout;
abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage, OutgoingMessage extends HttpMessage>
- implements ProtocolLayer, Identifiable, HttpConnection {
+ implements Identifiable, HttpConnection {
private enum ConnectionState { READY, ACTIVE, GRACEFUL_SHUTDOWN, SHUTDOWN}
@@ -100,7 +96,6 @@
private final ContentLengthStrategy outgoingContentStrategy;
private final ByteBuffer contentBuffer;
private final AtomicInteger outputRequests;
- private final Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup;
private volatile Message<IncomingMessage, ContentDecoder> incomingMessage;
private volatile Message<OutgoingMessage, ContentEncoder> outgoingMessage;
@@ -117,8 +112,7 @@
final NHttpMessageParser<IncomingMessage> incomingMessageParser,
final NHttpMessageWriter<OutgoingMessage> outgoingMessageWriter,
final ContentLengthStrategy incomingContentStrategy,
- final ContentLengthStrategy outgoingContentStrategy,
- final Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup) {
+ final ContentLengthStrategy outgoingContentStrategy) {
this.ioSession = Args.notNull(ioSession, "I/O session");
this.http1Config = http1Config != null ? http1Config : Http1Config.DEFAULT;
final int bufferSize = this.http1Config.getBufferSize();
@@ -136,7 +130,6 @@
DefaultContentLengthStrategy.INSTANCE;
this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
DefaultContentLengthStrategy.INSTANCE;
- this.protocolUpgradeHandlerLookup = protocolUpgradeHandlerLookup;
this.contentBuffer = ByteBuffer.allocate(this.http1Config.getBufferSize());
this.outputRequests = new AtomicInteger(0);
this.connState = ConnectionState.READY;
@@ -594,26 +587,6 @@
return tlsDetails != null ? tlsDetails.getSSLSession() : null;
}
- @Override
- public void upgrade(final ProtocolUpgradeHandler upgradeHandler,
- final EndpointParameters parameters) throws UnsupportedOperationException {
- Args.notNull(upgradeHandler, "Protocol upgrade handler");
- Args.notNull(parameters, "Endpoint parameters");
- upgradeHandler.upgrade(ioSession, parameters, null);
- }
-
- @Override
- public void upgrade(final String id,
- final EndpointParameters parameters) throws UnsupportedOperationException {
- Args.notNull(id, "Protocol id");
- Args.notNull(parameters, "Endpoint parameters");
- final ProtocolUpgradeHandler upgradeHandler = protocolUpgradeHandlerLookup.lookup(id);
- if (upgradeHandler == null) {
- throw new IllegalArgumentException("Unsupported protocol: " + id);
- }
- upgradeHandler.upgrade(ioSession, parameters, null);
- }
-
void appendState(final StringBuilder buf) {
buf.append("connState=").append(connState)
.append(", inbuf=").append(inbuf)
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
index 3cc6758..614056c 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
@@ -48,7 +48,6 @@
import org.apache.hc.core5.http.LengthRequiredException;
import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.Http1Config;
-import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
@@ -67,7 +66,6 @@
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.reactor.ProtocolIOSession;
-import org.apache.hc.core5.reactor.ProtocolUpgradeHandler;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.Asserts;
import org.apache.hc.core5.util.Timeout;
@@ -103,27 +101,8 @@
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final Http1StreamListener streamListener) {
- this(ioSession, httpProcessor, http1Config, charCodingConfig, connectionReuseStrategy, incomingMessageParser,
- outgoingMessageWriter, incomingContentStrategy, outgoingContentStrategy, null, streamListener);
- }
-
- /**
- * @since 5.1
- */
- public ClientHttp1StreamDuplexer(
- final ProtocolIOSession ioSession,
- final HttpProcessor httpProcessor,
- final Http1Config http1Config,
- final CharCodingConfig charCodingConfig,
- final ConnectionReuseStrategy connectionReuseStrategy,
- final NHttpMessageParser<HttpResponse> incomingMessageParser,
- final NHttpMessageWriter<HttpRequest> outgoingMessageWriter,
- final ContentLengthStrategy incomingContentStrategy,
- final ContentLengthStrategy outgoingContentStrategy,
- final Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup,
- final Http1StreamListener streamListener) {
super(ioSession, http1Config, charCodingConfig, incomingMessageParser, outgoingMessageWriter,
- incomingContentStrategy, outgoingContentStrategy, protocolUpgradeHandlerLookup);
+ incomingContentStrategy, outgoingContentStrategy);
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.http1Config = http1Config != null ? http1Config : Http1Config.DEFAULT;
this.connectionReuseStrategy = connectionReuseStrategy != null ? connectionReuseStrategy :
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexerFactory.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexerFactory.java
index 616f6a6..12544e8 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexerFactory.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexerFactory.java
@@ -36,7 +36,6 @@
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.Http1Config;
-import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
import org.apache.hc.core5.http.impl.Http1StreamListener;
@@ -44,7 +43,6 @@
import org.apache.hc.core5.http.nio.NHttpMessageWriterFactory;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.reactor.ProtocolIOSession;
-import org.apache.hc.core5.reactor.ProtocolUpgradeHandler;
import org.apache.hc.core5.util.Args;
/**
@@ -64,12 +62,8 @@
private final NHttpMessageWriterFactory<HttpRequest> requestWriterFactory;
private final ContentLengthStrategy incomingContentStrategy;
private final ContentLengthStrategy outgoingContentStrategy;
- private final Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup;
private final Http1StreamListener streamListener;
- /**
- * @since 5.1
- */
public ClientHttp1StreamDuplexerFactory(
final HttpProcessor httpProcessor,
final Http1Config http1Config,
@@ -79,7 +73,6 @@
final NHttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
- final Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup,
final Http1StreamListener streamListener) {
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.http1Config = http1Config != null ? http1Config : Http1Config.DEFAULT;
@@ -94,7 +87,6 @@
DefaultContentLengthStrategy.INSTANCE;
this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
DefaultContentLengthStrategy.INSTANCE;
- this.protocolUpgradeHandlerLookup = protocolUpgradeHandlerLookup;
this.streamListener = streamListener;
}
@@ -105,23 +97,9 @@
final ConnectionReuseStrategy connectionReuseStrategy,
final NHttpMessageParserFactory<HttpResponse> responseParserFactory,
final NHttpMessageWriterFactory<HttpRequest> requestWriterFactory,
- final ContentLengthStrategy incomingContentStrategy,
- final ContentLengthStrategy outgoingContentStrategy,
- final Http1StreamListener streamListener) {
- this(httpProcessor, http1Config, charCodingConfig, connectionReuseStrategy, responseParserFactory,
- requestWriterFactory, incomingContentStrategy, outgoingContentStrategy, null, streamListener);
- }
-
- public ClientHttp1StreamDuplexerFactory(
- final HttpProcessor httpProcessor,
- final Http1Config http1Config,
- final CharCodingConfig charCodingConfig,
- final ConnectionReuseStrategy connectionReuseStrategy,
- final NHttpMessageParserFactory<HttpResponse> responseParserFactory,
- final NHttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final Http1StreamListener streamListener) {
this(httpProcessor, http1Config, charCodingConfig, connectionReuseStrategy,
- responseParserFactory, requestWriterFactory, null, null, null, streamListener);
+ responseParserFactory, requestWriterFactory, null, null, streamListener);
}
public ClientHttp1StreamDuplexerFactory(
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java
index aab360e..2b6481b 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java
@@ -47,7 +47,6 @@
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.Http1Config;
-import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
@@ -66,7 +65,6 @@
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.reactor.ProtocolIOSession;
-import org.apache.hc.core5.reactor.ProtocolUpgradeHandler;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.Asserts;
import org.apache.hc.core5.util.Timeout;
@@ -106,30 +104,8 @@
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final Http1StreamListener streamListener) {
- this(ioSession, httpProcessor, exchangeHandlerFactory, scheme, http1Config, charCodingConfig,
- connectionReuseStrategy, incomingMessageParser, outgoingMessageWriter, incomingContentStrategy,
- outgoingContentStrategy, null, streamListener);
- }
-
- /**
- * @since 5.1
- */
- public ServerHttp1StreamDuplexer(
- final ProtocolIOSession ioSession,
- final HttpProcessor httpProcessor,
- final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
- final String scheme,
- final Http1Config http1Config,
- final CharCodingConfig charCodingConfig,
- final ConnectionReuseStrategy connectionReuseStrategy,
- final NHttpMessageParser<HttpRequest> incomingMessageParser,
- final NHttpMessageWriter<HttpResponse> outgoingMessageWriter,
- final ContentLengthStrategy incomingContentStrategy,
- final ContentLengthStrategy outgoingContentStrategy,
- final Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup,
- final Http1StreamListener streamListener) {
super(ioSession, http1Config, charCodingConfig, incomingMessageParser, outgoingMessageWriter,
- incomingContentStrategy, outgoingContentStrategy, protocolUpgradeHandlerLookup);
+ incomingContentStrategy, outgoingContentStrategy);
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Exchange handler factory");
this.scheme = scheme;
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexerFactory.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexerFactory.java
index c724dbc..5d1c646 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexerFactory.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexerFactory.java
@@ -36,7 +36,6 @@
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.Http1Config;
-import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
import org.apache.hc.core5.http.impl.Http1StreamListener;
@@ -46,7 +45,6 @@
import org.apache.hc.core5.http.nio.NHttpMessageWriterFactory;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.reactor.ProtocolIOSession;
-import org.apache.hc.core5.reactor.ProtocolUpgradeHandler;
import org.apache.hc.core5.util.Args;
/**
@@ -67,12 +65,8 @@
private final NHttpMessageWriterFactory<HttpResponse> responseWriterFactory;
private final ContentLengthStrategy incomingContentStrategy;
private final ContentLengthStrategy outgoingContentStrategy;
- private final Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup;
private final Http1StreamListener streamListener;
- /**
- * @since 5.1
- */
public ServerHttp1StreamDuplexerFactory(
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
@@ -83,7 +77,6 @@
final NHttpMessageWriterFactory<HttpResponse> responseWriterFactory,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
- final Lookup<ProtocolUpgradeHandler> protocolUpgradeHandlerLookup,
final Http1StreamListener streamListener) {
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Exchange handler factory");
@@ -99,7 +92,6 @@
DefaultContentLengthStrategy.INSTANCE;
this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
DefaultContentLengthStrategy.INSTANCE;
- this.protocolUpgradeHandlerLookup = protocolUpgradeHandlerLookup;
this.streamListener = streamListener;
}
@@ -111,26 +103,10 @@
final ConnectionReuseStrategy connectionReuseStrategy,
final NHttpMessageParserFactory<HttpRequest> requestParserFactory,
final NHttpMessageWriterFactory<HttpResponse> responseWriterFactory,
- final ContentLengthStrategy incomingContentStrategy,
- final ContentLengthStrategy outgoingContentStrategy,
- final Http1StreamListener streamListener) {
- this(httpProcessor, exchangeHandlerFactory, http1Config, charCodingConfig, connectionReuseStrategy,
- requestParserFactory, responseWriterFactory, incomingContentStrategy, outgoingContentStrategy,
- null, streamListener);
- }
-
- public ServerHttp1StreamDuplexerFactory(
- final HttpProcessor httpProcessor,
- final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
- final Http1Config http1Config,
- final CharCodingConfig charCodingConfig,
- final ConnectionReuseStrategy connectionReuseStrategy,
- final NHttpMessageParserFactory<HttpRequest> requestParserFactory,
- final NHttpMessageWriterFactory<HttpResponse> responseWriterFactory,
final Http1StreamListener streamListener) {
this(httpProcessor, exchangeHandlerFactory, http1Config, charCodingConfig,
connectionReuseStrategy, requestParserFactory, responseWriterFactory,
- null, null, null, streamListener);
+ null, null, streamListener);
}
public ServerHttp1StreamDuplexerFactory(
@@ -152,7 +128,6 @@
responseWriterFactory.create(),
incomingContentStrategy,
outgoingContentStrategy,
- protocolUpgradeHandlerLookup,
streamListener);
}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
index ed9be48..94571a8 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
@@ -32,7 +32,6 @@
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import java.nio.channels.SelectionKey;
-import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@@ -40,9 +39,7 @@
import javax.net.ssl.SSLContext;
-import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.function.Callback;
-import org.apache.hc.core5.http.ConnectionClosedException;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.net.NamedEndpoint;
import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
@@ -54,14 +51,13 @@
import org.apache.hc.core5.util.Asserts;
import org.apache.hc.core5.util.Timeout;
-final class InternalDataChannel extends InternalChannel implements ProtocolIOSession, TransportSecurityLayerEx {
+final class InternalDataChannel extends InternalChannel implements ProtocolIOSession {
private final IOSession ioSession;
private final NamedEndpoint initialEndpoint;
private final IOSessionListener sessionListener;
private final AtomicReference<SSLIOSession> tlsSessionRef;
private final Queue<InternalDataChannel> closedSessions;
- private final Queue<FutureCallback<ProtocolIOSession>> callbackQueue;
private final AtomicBoolean closed;
InternalDataChannel(
@@ -74,7 +70,6 @@
this.closedSessions = closedSessions;
this.sessionListener = sessionListener;
this.tlsSessionRef = new AtomicReference<>(null);
- this.callbackQueue = new LinkedList<>();
this.closed = new AtomicBoolean(false);
}
@@ -167,21 +162,18 @@
if (handler != null) {
handler.exception(this, cause);
}
- notifySubscribers(cause);
}
void onTLSSessionStart(final SSLIOSession sslSession) {
if (sessionListener != null) {
sessionListener.connected(this);
}
- notifySubscribers();
}
void onTLSSessionEnd() {
if (closed.compareAndSet(false, true)) {
closedSessions.add(this);
}
- cancelSubscribers();
}
void disconnected() {
@@ -245,53 +237,6 @@
}
@Override
- public void subscribe(final FutureCallback<ProtocolIOSession> callback) {
- if (callback == null) {
- return;
- }
- synchronized (callbackQueue) {
- if (getSessionImpl().getStatus() != Status.ACTIVE) {
- callback.failed(new ConnectionClosedException());
- return;
- }
- final SSLIOSession sslIoSession = tlsSessionRef.get();
- final TlsDetails tlsDetails = sslIoSession != null ? sslIoSession.getTlsDetails() : null;
- if (tlsDetails != null) {
- callback.completed(this);
- } else {
- callbackQueue.add(callback);
- }
- }
- }
-
- void notifySubscribers() {
- synchronized (callbackQueue) {
- FutureCallback<ProtocolIOSession> callback;
- while ((callback = callbackQueue.poll()) != null) {
- callback.completed(this);
- }
- }
- }
-
- void notifySubscribers(final Exception ex) {
- synchronized (callbackQueue) {
- FutureCallback<ProtocolIOSession> callback;
- while ((callback = callbackQueue.poll()) != null) {
- callback.failed(ex);
- }
- }
- }
-
- void cancelSubscribers() {
- synchronized (callbackQueue) {
- FutureCallback<ProtocolIOSession> callback;
- while ((callback = callbackQueue.poll()) != null) {
- callback.cancelled();
- }
- }
- }
-
- @Override
public Lock getLock() {
return ioSession.getLock();
}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ProtocolLayer.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ProtocolLayer.java
deleted file mode 100644
index 3b6533c..0000000
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ProtocolLayer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ====================================================================
- * 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.core5.reactor;
-
-import org.apache.hc.core5.annotation.Internal;
-
-/**
- * Application protocol layer interface.
- *
- * @since 5.1
- */
-@Internal
-public interface ProtocolLayer {
-
- /**
- * Switches to the given application protocol.
- */
- void upgrade(ProtocolUpgradeHandler handler, EndpointParameters parameters) throws UnsupportedOperationException;
-
- /**
- * Switches to the application protocol with the given protocol id.
- */
- void upgrade(String id, EndpointParameters parameters) throws UnsupportedOperationException;
-
-}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ProtocolUpgradeHandler.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ProtocolUpgradeHandler.java
deleted file mode 100644
index 5582484..0000000
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ProtocolUpgradeHandler.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * ====================================================================
- * 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.core5.reactor;
-
-import org.apache.hc.core5.annotation.Internal;
-import org.apache.hc.core5.concurrent.FutureCallback;
-
-/**
- * Application protocol upgrade handler.
- *
- * @since 5.1
- */
-@Internal
-public interface ProtocolUpgradeHandler {
-
- /**
- * Upgrades application protocol of the given I/O session.
- */
- void upgrade(ProtocolIOSession ioSession, EndpointParameters parameters, FutureCallback<ProtocolIOSession> callback);
-
-}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/TransportSecurityLayerEx.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/TransportSecurityLayerEx.java
deleted file mode 100644
index a41b907..0000000
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/TransportSecurityLayerEx.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * ====================================================================
- * 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.core5.reactor;
-
-import org.apache.hc.core5.annotation.Internal;
-import org.apache.hc.core5.concurrent.FutureCallback;
-import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
-
-/**
- * Application protocol layer interface.
- *
- * @since 5.1
- */
-@Internal
-public interface TransportSecurityLayerEx extends TransportSecurityLayer {
-
- /**
- * Adds subscription to the TLS handshake completion event.
- */
- void subscribe(FutureCallback<ProtocolIOSession> callback);
-
-}