From 261809380aeb5070f730a72a663b15aedbf355b5 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 31 Jan 2013 12:29:43 -0700 Subject: [PATCH] 395444 - Disabling Websocket Compress Extensions (not working with Chrome / deflate problem) + Adding test case example of many server messages in a row + Disabling various compression extensions till a solution is found --- .../common/extensions/ExtensionStack.java | 5 ++++ .../extensions/WebSocketExtensionFactory.java | 6 +++-- .../jetty/websocket/server/ChromeTest.java | 2 ++ .../server/FrameCompressionExtensionTest.java | 2 ++ .../server/browser/BrowserSocket.java | 26 ++++++++++++++++++- .../websocket/server/helper/EchoServlet.java | 7 +++++ .../resources/browser-debug-tool/index.html | 2 ++ .../resources/browser-debug-tool/websocket.js | 1 + .../test/resources/jetty-logging.properties | 3 ++- 9 files changed, 50 insertions(+), 4 deletions(-) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStack.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStack.java index b312c88d9f1..b962aecc79e 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStack.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStack.java @@ -218,6 +218,11 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames for (ExtensionConfig config : configs) { Extension ext = factory.newInstance(config); + if (ext == null) + { + // Extension not present on this side + continue; + } extensions.add(ext); LOG.debug("Adding Extension: {}",ext); } diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionFactory.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionFactory.java index df3fcf2d494..6ed92244486 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionFactory.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionFactory.java @@ -43,8 +43,10 @@ public class WebSocketExtensionFactory extends ExtensionFactory register("identity",IdentityExtension.class); register("fragment",FragmentExtension.class); - register("x-webkit-deflate-frame",FrameCompressionExtension.class); - register("permessage-compress",MessageCompressionExtension.class); + /* FIXME: Disabled due to bug report - http://bugs.eclipse.org/395444 + * register("x-webkit-deflate-frame",FrameCompressionExtension.class); + * register("permessage-compress",MessageCompressionExtension.class); + */ } @Override diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ChromeTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ChromeTest.java index f85a0905e2c..fd16ef78686 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ChromeTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ChromeTest.java @@ -29,8 +29,10 @@ import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; +@Ignore("Bug 395444") public class ChromeTest { private static SimpleServletServer server; diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FrameCompressionExtensionTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FrameCompressionExtensionTest.java index 4944c52c4fa..9e0dfebc295 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FrameCompressionExtensionTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FrameCompressionExtensionTest.java @@ -29,6 +29,7 @@ import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; public class FrameCompressionExtensionTest @@ -49,6 +50,7 @@ public class FrameCompressionExtensionTest } @Test + @Ignore("Bug 395444") public void testDeflateFrameExtension() throws Exception { BlockheadClient client = new BlockheadClient(server.getServerUri()); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserSocket.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserSocket.java index 20a644ccebf..7dc9269178b 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserSocket.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserSocket.java @@ -22,6 +22,7 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Locale; +import java.util.Random; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.log.Log; @@ -92,6 +93,29 @@ public class BrowserSocket } break; } + case "many": + { + String parts[] = val.split(","); + int size = Integer.parseInt(parts[0]); + int count = Integer.parseInt(parts[1]); + + char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-|{}[]():".toCharArray(); + int lettersLen = letters.length; + char randomText[] = new char[size]; + Random rand = new Random(); + + for (int n = 0; n < count; n++) + { + // create random text + for (int i = 0; i < size; i++) + { + randomText[i] = letters[rand.nextInt(lettersLen)]; + } + writeMessage("Many [%s]",String.valueOf(randomText)); + } + + break; + } case "time": { Calendar now = Calendar.getInstance(); @@ -107,7 +131,7 @@ public class BrowserSocket } else { - // echo it + // Not parameterized, echo it back writeMessage(message); } } diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/EchoServlet.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/EchoServlet.java index 8dd389c2770..7cbbd2e0e77 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/EchoServlet.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/EchoServlet.java @@ -18,6 +18,8 @@ package org.eclipse.jetty.websocket.server.helper; +import org.eclipse.jetty.websocket.common.extensions.compress.FrameCompressionExtension; +import org.eclipse.jetty.websocket.common.extensions.compress.MessageCompressionExtension; import org.eclipse.jetty.websocket.servlet.WebSocketServlet; import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory; @@ -30,6 +32,11 @@ public class EchoServlet extends WebSocketServlet @Override public void configure(WebSocketServletFactory factory) { + // Setup some extensions we want to test against + factory.getExtensionFactory().register("x-webkit-deflate-frame",FrameCompressionExtension.class); + factory.getExtensionFactory().register("permessage-compress",MessageCompressionExtension.class); + + // Setup the desired Socket to use for all incoming upgrade requests factory.register(EchoSocket.class); } } diff --git a/jetty-websocket/websocket-server/src/test/resources/browser-debug-tool/index.html b/jetty-websocket/websocket-server/src/test/resources/browser-debug-tool/index.html index 1ad687f294c..328cbb14d57 100644 --- a/jetty-websocket/websocket-server/src/test/resources/browser-debug-tool/index.html +++ b/jetty-websocket/websocket-server/src/test/resources/browser-debug-tool/index.html @@ -12,6 +12,7 @@ + @@ -20,6 +21,7 @@ $("close").onclick = function(event) {wstool.close(); return false; } $("info").onclick = function(event) {wstool.write("info:"); return false; } $("time").onclick = function(event) {wstool.write("time:"); return false; } + $("many").onclick = function(event) {wstool.write("many:15,30"); return false; } $("hello").onclick = function(event) {wstool.write("Hello"); return false; } $("there").onclick = function(event) {wstool.write("There"); return false; } diff --git a/jetty-websocket/websocket-server/src/test/resources/browser-debug-tool/websocket.js b/jetty-websocket/websocket-server/src/test/resources/browser-debug-tool/websocket.js index b02263a71e2..9e0caa20922 100644 --- a/jetty-websocket/websocket-server/src/test/resources/browser-debug-tool/websocket.js +++ b/jetty-websocket/websocket-server/src/test/resources/browser-debug-tool/websocket.js @@ -69,6 +69,7 @@ var wstool = { $('close').disabled = !enabled; $('info').disabled = !enabled; $('time').disabled = !enabled; + $('many').disabled = !enabled; $('hello').disabled = !enabled; $('there').disabled = !enabled; }, diff --git a/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties b/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties index 523b9ad6c59..c27be6164a8 100644 --- a/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties +++ b/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties @@ -13,7 +13,8 @@ org.eclipse.jetty.LEVEL=WARN # org.eclipse.jetty.websocket.server.helper.LEVEL=DEBUG ### Show state changes on BrowserDebugTool -# org.eclipse.jetty.websocket.server.browser.LEVEL=DEBUG +# -- LEAVE THIS AT DEBUG LEVEL -- +org.eclipse.jetty.websocket.server.browser.LEVEL=DEBUG ### Disabling intentional error out of RFCSocket org.eclipse.jetty.websocket.server.helper.RFCSocket.LEVEL=OFF