From 4055146dcdd954c62f482c70fa16c2bc0aec03fd Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 13 Jul 2016 11:09:33 +1000 Subject: [PATCH] Fix #671 Incorrect default SLPN protocol --- .../jetty/http2/alpn/tests/ALPNNegotiationTest.java | 1 - .../jetty/server/NegotiatingServerConnectionFactory.java | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/jetty-http2/http2-alpn-tests/src/test/java/org/eclipse/jetty/http2/alpn/tests/ALPNNegotiationTest.java b/jetty-http2/http2-alpn-tests/src/test/java/org/eclipse/jetty/http2/alpn/tests/ALPNNegotiationTest.java index 0d366114cec..1cafaed344a 100644 --- a/jetty-http2/http2-alpn-tests/src/test/java/org/eclipse/jetty/http2/alpn/tests/ALPNNegotiationTest.java +++ b/jetty-http2/http2-alpn-tests/src/test/java/org/eclipse/jetty/http2/alpn/tests/ALPNNegotiationTest.java @@ -31,7 +31,6 @@ import java.util.List; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; -import javax.net.ssl.SSLEngineResult; import javax.net.ssl.SSLSocket; import org.eclipse.jetty.alpn.ALPN; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/NegotiatingServerConnectionFactory.java b/jetty-server/src/main/java/org/eclipse/jetty/server/NegotiatingServerConnectionFactory.java index 22c780c5522..ff1e5cdfa95 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/NegotiatingServerConnectionFactory.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/NegotiatingServerConnectionFactory.java @@ -24,6 +24,7 @@ import java.util.List; import javax.net.ssl.SSLEngine; +import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; @@ -110,10 +111,15 @@ public abstract class NegotiatingServerConnectionFactory extends AbstractConnect } } - // if default protocol is not set, then it is the first protocol given + // if default protocol is not set, then it is either HTTP/1.1 or + // the first protocol given String dft = defaultProtocol; if (dft == null && !negotiated.isEmpty()) + { + if (negotiated.contains(HttpVersion.HTTP_1_1.asString())) + dft = HttpVersion.HTTP_1_1.asString(); dft = negotiated.get(0); + } SSLEngine engine = null; EndPoint ep = endPoint;