Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2016-01-15 20:23:06 +0000
committerJoakim Erdfelt2016-01-15 20:23:43 +0000
commit9f8df9a1a84433cdaf4b52471210f63d6e005f2d (patch)
tree7194f257a77cd777c935306de749e0aa1cb183dd
parentd41c0bba65d7b95ef5d80270b84010e67c5f94c8 (diff)
downloadorg.eclipse.jetty.project-9f8df9a1a84433cdaf4b52471210f63d6e005f2d.tar.gz
org.eclipse.jetty.project-9f8df9a1a84433cdaf4b52471210f63d6e005f2d.tar.xz
org.eclipse.jetty.project-9f8df9a1a84433cdaf4b52471210f63d6e005f2d.zip
485969 - WebSocket upgrade response should honor HttpConfiguration server version settings
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/browser/JsrBrowserDebugTool.java8
-rw-r--r--jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java22
2 files changed, 29 insertions, 1 deletions
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/browser/JsrBrowserDebugTool.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/browser/JsrBrowserDebugTool.java
index 691a41a757..ce8d230bbb 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/browser/JsrBrowserDebugTool.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/browser/JsrBrowserDebugTool.java
@@ -21,6 +21,8 @@ package org.eclipse.jetty.websocket.jsr356.server.browser;
import javax.servlet.ServletException;
import javax.websocket.DeploymentException;
+import org.eclipse.jetty.server.HttpConfiguration;
+import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.DefaultServlet;
@@ -79,7 +81,11 @@ public class JsrBrowserDebugTool
private void setupServer(int port) throws DeploymentException, ServletException
{
server = new Server();
- ServerConnector connector = new ServerConnector(server);
+
+ HttpConfiguration httpConf = new HttpConfiguration();
+ httpConf.setSendServerVersion(true);
+
+ ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConf));
connector.setPort(port);
server.addConnector(connector);
diff --git a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java
index e30b4cac5d..c55f7a0a01 100644
--- a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java
+++ b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java
@@ -36,11 +36,15 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.HttpStatus;
+import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.MappedByteBufferPool;
+import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.DecoratedObjectFactory;
@@ -618,6 +622,9 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
if (LOG.isDebugEnabled())
LOG.debug("Handshake Response: {}", handshaker);
+ if (getSendServerVersion(connector))
+ response.setHeader("Server",HttpConfiguration.SERVER_VERSION);
+
// Process (version specific) handshake response
handshaker.doHandshakeResponse(request, response);
@@ -626,4 +633,19 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
return true;
}
+
+ private boolean getSendServerVersion(Connector connector)
+ {
+ ConnectionFactory connFactory = connector.getConnectionFactory(HttpVersion.HTTP_1_1.asString());
+ if (connFactory == null)
+ return false;
+
+ if (connFactory instanceof HttpConnectionFactory)
+ {
+ HttpConfiguration httpConf = ((HttpConnectionFactory)connFactory).getHttpConfiguration();
+ if (httpConf != null)
+ return httpConf.getSendServerVersion();
+ }
+ return false;
+ }
}

Back to the top