diff options
author | Greg Wilkins | 2015-02-13 01:16:03 +0000 |
---|---|---|
committer | Greg Wilkins | 2015-02-13 01:16:03 +0000 |
commit | c3332e7d2e3ed3b94cbcceed9bb11d02cf5018d7 (patch) | |
tree | 91df313504f4288df7a7b2aabe6abc64b60b096e /jetty-http2/http2-server/src/main | |
parent | 0f7ee8d607d9f74debe0698237e46b20375680a9 (diff) | |
download | org.eclipse.jetty.project-c3332e7d2e3ed3b94cbcceed9bb11d02cf5018d7.tar.gz org.eclipse.jetty.project-c3332e7d2e3ed3b94cbcceed9bb11d02cf5018d7.tar.xz org.eclipse.jetty.project-c3332e7d2e3ed3b94cbcceed9bb11d02cf5018d7.zip |
459845 - Support upgrade from http1 to http2/websocket
Added support for unofficial "upgrade" from http/1 to h2c
Diffstat (limited to 'jetty-http2/http2-server/src/main')
4 files changed, 68 insertions, 27 deletions
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 4c5a50663d..10734a162b 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 @@ -42,19 +42,13 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne public AbstractHTTP2ServerConnectionFactory(@Name("config") HttpConfiguration httpConfiguration) { - super("h2-17","h2-16","h2-15","h2-14","h2"); - this.httpConfiguration = httpConfiguration; + this(httpConfiguration,"h2-17","h2-16","h2-15","h2-14","h2"); } - - @Deprecated - public boolean isDispatchIO() - { - return false; - } - - @Deprecated - public void setDispatchIO(boolean dispatchIO) + + protected AbstractHTTP2ServerConnectionFactory(@Name("config") HttpConfiguration httpConfiguration,String... protocols) { + super(protocols); + this.httpConfiguration = httpConfiguration; } public int getMaxDynamicTableSize() @@ -108,7 +102,7 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne // stream idle timeout will expire earlier that the connection's. session.setStreamIdleTimeout(endPoint.getIdleTimeout()); - Parser parser = newServerParser(connector.getByteBufferPool(), session); + Parser parser = newServerParser(connector, session); HTTP2Connection connection = new HTTP2ServerConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, httpConfiguration, parser, session, getInputBufferSize(), listener); @@ -122,5 +116,8 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne protected abstract ServerSessionListener newSessionListener(Connector connector, EndPoint endPoint); - protected abstract ServerParser newServerParser(ByteBufferPool byteBufferPool, ServerParser.Listener listener); + protected ServerParser newServerParser(Connector connector, ServerParser.Listener listener) + { + return new ServerParser(connector.getByteBufferPool(), listener, getMaxDynamicTableSize(), getHttpConfiguration().getRequestHeaderSize()); + } } 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 new file mode 100644 index 0000000000..af7365033e --- /dev/null +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2CServerConnectionFactory.java @@ -0,0 +1,53 @@ +// +// ======================================================================== +// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.http2.server; + +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; + +public class HTTP2CServerConnectionFactory extends HTTP2ServerConnectionFactory +{ + public HTTP2CServerConnectionFactory(HttpConfiguration httpConfiguration) + { + super(httpConfiguration,"h2c"); + } + + @Override + public boolean isAcceptable(String protocol, String tlsProtocol, String tlsCipher) + { + // Never use TLS with h2c + return false; + } + + protected ServerParser newServerParser(Connector connector, ServerParser.Listener listener) + { + ServerParser parser = super.newServerParser(connector,listener); + + if (connector.getDefaultConnectionFactory() instanceof HttpConnectionFactory) + { + // This must be a sneaky upgrade from HTTP/1 + // So advance the parsers pointer until after the PRI * HTTP/2.0 request. + parser.directUpgrade(); + } + + return parser; + } +} diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java index 9dbcc8964b..091563d532 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java @@ -51,17 +51,16 @@ public class HTTP2ServerConnectionFactory extends AbstractHTTP2ServerConnectionF { super(httpConfiguration); } - - @Override - protected ServerSessionListener newSessionListener(Connector connector, EndPoint endPoint) + + protected HTTP2ServerConnectionFactory(@Name("config") HttpConfiguration httpConfiguration,String... protocols) { - return new HTTPServerSessionListener(connector, endPoint); + super(httpConfiguration,protocols); } @Override - protected ServerParser newServerParser(ByteBufferPool byteBufferPool, ServerParser.Listener listener) + protected ServerSessionListener newSessionListener(Connector connector, EndPoint endPoint) { - return new ServerParser(byteBufferPool, listener, getMaxDynamicTableSize(), getHttpConfiguration().getRequestHeaderSize()); + return new HTTPServerSessionListener(connector, endPoint); } @Override diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/RawHTTP2ServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/RawHTTP2ServerConnectionFactory.java index aeb7e19e6a..923fc6466b 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/RawHTTP2ServerConnectionFactory.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/RawHTTP2ServerConnectionFactory.java @@ -19,8 +19,6 @@ package org.eclipse.jetty.http2.server; import org.eclipse.jetty.http2.api.server.ServerSessionListener; -import org.eclipse.jetty.http2.parser.ServerParser; -import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.HttpConfiguration; @@ -40,10 +38,4 @@ public class RawHTTP2ServerConnectionFactory extends AbstractHTTP2ServerConnecti { return listener; } - - @Override - protected ServerParser newServerParser(ByteBufferPool byteBufferPool, ServerParser.Listener listener) - { - return new ServerParser(byteBufferPool, listener, getMaxDynamicTableSize(), getHttpConfiguration().getRequestHeaderSize()); - } } |