Fix closing handshake and run against Autobahn V0.4.3
This commit is contained in:
parent
1bb3322268
commit
8efe131eb0
@ -32,20 +32,23 @@
|
||||
*
|
||||
* <p>06. Go to AutoBahn directory: <tt>cd Autobahn</tt>
|
||||
*
|
||||
* <p>07. Checkout stable version: <tt>git checkout v0.4.2</tt>
|
||||
* <p>07. Checkout stable version: <tt>git checkout v0.4.3</tt>
|
||||
*
|
||||
* <p>08. Go to test suite directory: <tt>cd testsuite/websockets</tt>
|
||||
*
|
||||
* <p>09. Edit <tt>fuzzing_clinet_spec.json</tt> and set the version to 10.
|
||||
* <p>09. Edit <tt>fuzzing_clinet_spec.json</tt> and set the version to 10 or 17.
|
||||
* <code>
|
||||
* {
|
||||
* "servers": [{"agent": "Netty", "hostname": "localhost", "port": 9000, "version": 10}],
|
||||
* "cases": ["*"]
|
||||
* "options": {"failByDrop": false},
|
||||
* "servers": [{"agent": "Netty", "url": "ws://localhost:9000", "options": {"version": 17}}],
|
||||
* "cases": ["*"],
|
||||
* "exclude-cases": [],
|
||||
* "exclude-agent-cases": {"FoobarServer*": ["4.*", "1.1.3"]}
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* <p>10. Run the test <tt>python fuzzing_client.py</tt>. Note that the actual test case python code is
|
||||
* located in <tt>/usr/local/lib/python2.6/dist-packages/autobahn-0.4.2-py2.6.egg/autobahn/cases</tt>
|
||||
* located in <tt>/usr/local/lib/python2.6/dist-packages/autobahn-0.4.3-py2.6.egg/autobahn/cases</tt>
|
||||
* and not in the checked out git repository.
|
||||
*
|
||||
* <p>11. See the results in <tt>reports/servers/index.html</tt>
|
||||
|
@ -260,7 +260,17 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
||||
unmask(framePayload);
|
||||
}
|
||||
|
||||
// Processing for fragmented messages
|
||||
// Processing ping/pong/close frames because they cannot be fragmented
|
||||
if (frameOpcode == OPCODE_PING) {
|
||||
return new PingWebSocketFrame(frameFinalFlag, frameRsv, framePayload);
|
||||
} else if (frameOpcode == OPCODE_PONG) {
|
||||
return new PongWebSocketFrame(frameFinalFlag, frameRsv, framePayload);
|
||||
} else if (frameOpcode == OPCODE_CLOSE) {
|
||||
this.receivedClosingHandshake = true;
|
||||
return new CloseWebSocketFrame(frameFinalFlag, frameRsv);
|
||||
}
|
||||
|
||||
// Processing for possible fragmented messages for text and binary frames
|
||||
String aggregatedText = null;
|
||||
if (frameFinalFlag) {
|
||||
// Final frame of the sequence. Apparently ping frames are
|
||||
@ -305,15 +315,8 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
||||
return new TextWebSocketFrame(frameFinalFlag, frameRsv, framePayload);
|
||||
} else if (frameOpcode == OPCODE_BINARY) {
|
||||
return new BinaryWebSocketFrame(frameFinalFlag, frameRsv, framePayload);
|
||||
} else if (frameOpcode == OPCODE_PING) {
|
||||
return new PingWebSocketFrame(frameFinalFlag, frameRsv, framePayload);
|
||||
} else if (frameOpcode == OPCODE_PONG) {
|
||||
return new PongWebSocketFrame(frameFinalFlag, frameRsv, framePayload);
|
||||
} else if (frameOpcode == OPCODE_CONT) {
|
||||
return new ContinuationWebSocketFrame(frameFinalFlag, frameRsv, framePayload, aggregatedText);
|
||||
} else if (frameOpcode == OPCODE_CLOSE) {
|
||||
this.receivedClosingHandshake = true;
|
||||
return new CloseWebSocketFrame(frameFinalFlag, frameRsv);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Cannot decode web socket frame with opcode: " + frameOpcode);
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelFutureListener;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
|
||||
@ -150,7 +152,7 @@ public class WebSocketServerHandshaker10 extends WebSocketServerHandshaker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Echo back the closing frame
|
||||
* Echo back the closing frame and close the connection
|
||||
*
|
||||
* @param ctx
|
||||
* Channel context
|
||||
@ -159,7 +161,8 @@ public class WebSocketServerHandshaker10 extends WebSocketServerHandshaker {
|
||||
*/
|
||||
@Override
|
||||
public void executeClosingHandshake(ChannelHandlerContext ctx, CloseWebSocketFrame frame) {
|
||||
ctx.getChannel().write(frame);
|
||||
ChannelFuture f = ctx.getChannel().write(frame);
|
||||
f.addListener(ChannelFutureListener.CLOSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user