399689 - Websocket RFC6455 extension handshake fails if server doesn't have extension

+ Fixing the fix that fixed the negotation to fix a bad fixation of the
  negotiated extensions
This commit is contained in:
Joakim Erdfelt 2013-01-31 16:14:30 -07:00
parent 552ec4ae36
commit 89d8972e74
7 changed files with 15 additions and 12 deletions

View File

@ -33,7 +33,7 @@ import org.eclipse.jetty.websocket.common.extensions.AbstractExtension;
*/ */
public class FrameCompressionExtension extends AbstractExtension public class FrameCompressionExtension extends AbstractExtension
{ {
private DeflateCompressionMethod method; private CompressionMethod method = new DeflateCompressionMethod();
@Override @Override
public void incomingFrame(Frame frame) public void incomingFrame(Frame frame)
@ -121,8 +121,6 @@ public class FrameCompressionExtension extends AbstractExtension
public void setConfig(ExtensionConfig config) public void setConfig(ExtensionConfig config)
{ {
super.setConfig(config); super.setConfig(config);
method = new DeflateCompressionMethod();
} }
@Override @Override

View File

@ -55,7 +55,6 @@ public class HandshakeRFC6455 implements WebSocketHandshake
if (response.getExtensions() != null) if (response.getExtensions() != null)
{ {
response.setExtensions(response.getExtensions());
for (ExtensionConfig ext : response.getExtensions()) for (ExtensionConfig ext : response.getExtensions())
{ {
response.addHeader("Sec-WebSocket-Extensions",ext.getParameterizedName()); response.addHeader("Sec-WebSocket-Extensions",ext.getParameterizedName());

View File

@ -72,8 +72,8 @@ public abstract class WebSocketHandler extends HandlerWrapper
@Override @Override
protected void doStart() throws Exception protected void doStart() throws Exception
{ {
super.doStart();
configure(webSocketFactory); configure(webSocketFactory);
super.doStart();
} }
public WebSocketServletFactory getWebSocketFactory() public WebSocketServletFactory getWebSocketFactory()

View File

@ -25,6 +25,8 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.UpgradeRequest; import org.eclipse.jetty.websocket.api.UpgradeRequest;
import org.eclipse.jetty.websocket.api.UpgradeResponse; import org.eclipse.jetty.websocket.api.UpgradeResponse;
import org.eclipse.jetty.websocket.common.extensions.compress.FrameCompressionExtension;
import org.eclipse.jetty.websocket.common.extensions.compress.MessageCompressionExtension;
import org.eclipse.jetty.websocket.server.WebSocketHandler; import org.eclipse.jetty.websocket.server.WebSocketHandler;
import org.eclipse.jetty.websocket.servlet.WebSocketCreator; import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory; import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
@ -109,8 +111,8 @@ public class BrowserDebugTool implements WebSocketCreator
LOG.debug("Configuring WebSocketServerFactory ..."); LOG.debug("Configuring WebSocketServerFactory ...");
// Setup some extensions we want to test against // Setup some extensions we want to test against
// factory.getExtensionFactory().register("x-webkit-deflate-frame",FrameCompressionExtension.class); factory.getExtensionFactory().register("x-webkit-deflate-frame",FrameCompressionExtension.class);
// factory.getExtensionFactory().register("permessage-compress",MessageCompressionExtension.class); factory.getExtensionFactory().register("permessage-compress",MessageCompressionExtension.class);
// Setup the desired Socket to use for all incoming upgrade requests // Setup the desired Socket to use for all incoming upgrade requests
factory.setCreator(BrowserDebugTool.this); factory.setCreator(BrowserDebugTool.this);

View File

@ -56,7 +56,7 @@ public class BrowserSocket
char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-|{}[]():".toCharArray(); char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-|{}[]():".toCharArray();
int lettersLen = letters.length; int lettersLen = letters.length;
char randomText[] = new char[size]; char randomText[] = new char[size];
Random rand = new Random(); Random rand = new Random(42);
String msg; String msg;
for (int n = 0; n < count; n++) for (int n = 0; n < count; n++)
@ -66,7 +66,7 @@ public class BrowserSocket
{ {
randomText[i] = letters[rand.nextInt(lettersLen)]; randomText[i] = letters[rand.nextInt(lettersLen)];
} }
msg = String.format("Many [%s]",String.valueOf(randomText)); msg = String.format("ManyThreads [%s]",String.valueOf(randomText));
remote.sendStringByFuture(msg); remote.sendStringByFuture(msg);
} }
} }
@ -88,6 +88,7 @@ public class BrowserSocket
@OnWebSocketConnect @OnWebSocketConnect
public void onConnect(Session session) public void onConnect(Session session)
{ {
LOG.info("Connect [{}]",session);
this.session = session; this.session = session;
this.remote = session.getRemote(); this.remote = session.getRemote();
} }
@ -190,7 +191,7 @@ public class BrowserSocket
char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-|{}[]():".toCharArray(); char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-|{}[]():".toCharArray();
int lettersLen = letters.length; int lettersLen = letters.length;
char randomText[] = new char[size]; char randomText[] = new char[size];
Random rand = new Random(); Random rand = new Random(42);
for (int n = 0; n < count; n++) for (int n = 0; n < count; n++)
{ {

View File

@ -22,7 +22,7 @@
$("close").onclick = function(event) {wstool.close(); return false; } $("close").onclick = function(event) {wstool.close(); return false; }
$("info").onclick = function(event) {wstool.write("info:"); return false; } $("info").onclick = function(event) {wstool.write("info:"); return false; }
$("time").onclick = function(event) {wstool.write("time:"); return false; } $("time").onclick = function(event) {wstool.write("time:"); return false; }
$("many").onclick = function(event) {wstool.write("many:15,30"); return false; } $("many").onclick = function(event) {wstool.write("many:15,300"); return false; }
$("manythreads").onclick = function(event) {wstool.write("manythreads:20,25,60"); return false; } $("manythreads").onclick = function(event) {wstool.write("manythreads:20,25,60"); return false; }
$("hello").onclick = function(event) {wstool.write("Hello"); return false; } $("hello").onclick = function(event) {wstool.write("Hello"); return false; }
$("there").onclick = function(event) {wstool.write("There"); return false; } $("there").onclick = function(event) {wstool.write("There"); return false; }

View File

@ -27,6 +27,8 @@ var wstool = {
wstool.info("Document URI: " + document.location); wstool.info("Document URI: " + document.location);
wstool.info("WS URI: " + location); wstool.info("WS URI: " + location);
this._scount = 0;
try { try {
this._ws = new WebSocket(location, "tool"); this._ws = new WebSocket(location, "tool");
this._ws.onopen = this._onopen; this._ws.onopen = this._onopen;
@ -61,7 +63,8 @@ var wstool = {
}, },
infos : function(message) { infos : function(message) {
wstool._out("server", "[s] " + message); this._scount++;
wstool._out("server", "[s" + this._scount + "] " + message);
}, },
setState : function(enabled) { setState : function(enabled) {