From c090f179a7c3bab138aa14bf08abaab9e3cd27d3 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 13 Feb 2015 15:06:24 +1100 Subject: [PATCH] 459845 - Support upgrade from http1 to http2/websocket Added jetty-http2c.xml and http2c.mod --- .../src/main/config/etc/jetty-http2c.xml | 17 ++++++++++++++ .../src/main/config/modules/http2c.mod | 22 +++++++++++++++++++ .../AbstractHTTP2ServerConnectionFactory.java | 2 ++ .../server/HTTP2CServerConnectionFactory.java | 17 +++++++++++++- .../src/main/config/etc/jetty-http.xml | 2 +- .../jetty/server/HttpConnectionFactory.java | 13 ++--------- 6 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 jetty-http2/http2-server/src/main/config/etc/jetty-http2c.xml create mode 100644 jetty-http2/http2-server/src/main/config/modules/http2c.mod diff --git a/jetty-http2/http2-server/src/main/config/etc/jetty-http2c.xml b/jetty-http2/http2-server/src/main/config/etc/jetty-http2c.xml new file mode 100644 index 00000000000..1077a5c9d2a --- /dev/null +++ b/jetty-http2/http2-server/src/main/config/etc/jetty-http2c.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/jetty-http2/http2-server/src/main/config/modules/http2c.mod b/jetty-http2/http2-server/src/main/config/modules/http2c.mod new file mode 100644 index 00000000000..1073181bb38 --- /dev/null +++ b/jetty-http2/http2-server/src/main/config/modules/http2c.mod @@ -0,0 +1,22 @@ +# +# HTTP2 Clear Text Support Module +# + +[depend] +http + +[lib] +lib/http2/*.jar + +[xml] +etc/jetty-http2c.xml + +[ini-template] +## HTTP2c Configuration + +# This module adds support for HTTP/2 clear text to the +# HTTP/1 clear text connector (defined in jetty-http.xml) +# The resulting connector will accept both HTTP/1 and HTTP/2 +# connections + +# http2.maxConcurrentStreams=1024 diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java index 8696dc7ee76..ac986232f57 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java @@ -47,6 +47,8 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne protected AbstractHTTP2ServerConnectionFactory(@Name("config") HttpConfiguration httpConfiguration,String... protocols) { super(protocols); + if (httpConfiguration==null) + throw new IllegalArgumentException("Null HttpConfiguration"); this.httpConfiguration = httpConfiguration; } diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2CServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2CServerConnectionFactory.java index af7365033e2..d9667f30349 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2CServerConnectionFactory.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2CServerConnectionFactory.java @@ -22,10 +22,25 @@ import org.eclipse.jetty.http2.parser.ServerParser; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; +import org.eclipse.jetty.util.annotation.Name; + +/* ------------------------------------------------------------ */ +/** HTTP2 Clear Text Connection factory. + *

This extension of HTTP2ServerConnection Factory sets the + * protocol name to "h2c" as used by the clear text upgrade mechanism + * for HTTP2 and marks all TLS ciphers as unacceptable. + *

+ *

If used in combination with a {@link HttpConnectionFactory} as the + * default protocol, this factory can support the non-standard direct + * update mechanism, where a HTTP1 request of the form "PRI * HTTP/2.0" + * is used to trigger a switch to a HTTP2 connection. This approach + * allows a single port to accept either HTTP/1 or HTTP/2 direct + * connections. + */ public class HTTP2CServerConnectionFactory extends HTTP2ServerConnectionFactory { - public HTTP2CServerConnectionFactory(HttpConfiguration httpConfiguration) + public HTTP2CServerConnectionFactory(@Name("config") HttpConfiguration httpConfiguration) { super(httpConfiguration,"h2c"); } diff --git a/jetty-server/src/main/config/etc/jetty-http.xml b/jetty-server/src/main/config/etc/jetty-http.xml index 8456a14d4ba..adeeaae331a 100644 --- a/jetty-server/src/main/config/etc/jetty-http.xml +++ b/jetty-server/src/main/config/etc/jetty-http.xml @@ -20,7 +20,7 @@ - + diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnectionFactory.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnectionFactory.java index 577a9f82c95..9926325146a 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnectionFactory.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnectionFactory.java @@ -41,6 +41,8 @@ public class HttpConnectionFactory extends AbstractConnectionFactory implements { super(HttpVersion.HTTP_1_1.asString()); _config=config; + if (config==null) + throw new IllegalArgumentException("Null HttpConfiguration"); addBean(_config); } @@ -50,17 +52,6 @@ public class HttpConnectionFactory extends AbstractConnectionFactory implements return _config; } - @Deprecated - public boolean isDispatchIO() - { - return false; - } - - @Deprecated - public void setDispatchIO(boolean dispatchIO) - { - } - @Override public Connection newConnection(Connector connector, EndPoint endPoint) {