summaryrefslogtreecommitdiff
path: root/flash-src/src/net/gimite/websocket/WebSocket.as
diff options
context:
space:
mode:
authorHiroshi Ichikawa <gimite@gmail.com>2011-11-05 19:58:11 +0900
committerHiroshi Ichikawa <gimite@gmail.com>2011-11-05 19:58:11 +0900
commit14023075bfa7350a3a2268cb6d7e38e046b24bcf (patch)
treeac1f72ab70a090178e2276b64dd9347bc0b5ebb8 /flash-src/src/net/gimite/websocket/WebSocket.as
parent55ae639a2ee607dea2ba40df608588f1b840a9cc (diff)
downloadweb-socket-js-14023075bfa7350a3a2268cb6d7e38e046b24bcf.tar.gz
Closing connection on masked frame from server. Issue #103
Diffstat (limited to 'flash-src/src/net/gimite/websocket/WebSocket.as')
-rw-r--r--flash-src/src/net/gimite/websocket/WebSocket.as7
1 files changed, 7 insertions, 0 deletions
diff --git a/flash-src/src/net/gimite/websocket/WebSocket.as b/flash-src/src/net/gimite/websocket/WebSocket.as
index 6a47283..111b705 100644
--- a/flash-src/src/net/gimite/websocket/WebSocket.as
+++ b/flash-src/src/net/gimite/websocket/WebSocket.as
@@ -323,6 +323,8 @@ public class WebSocket extends EventDispatcher {
pos = -1;
if (frame.rsv != 0) {
close(1002, "RSV must be 0.");
+ } else if (frame.mask) {
+ close(1002, "Frame from server must not be masked.");
} else if (frame.opcode >= 0x08 && frame.opcode <= 0x0f && frame.payload.length >= 126) {
close(1004, "Payload of control frame must be less than 126 bytes.");
} else {
@@ -339,6 +341,8 @@ public class WebSocket extends EventDispatcher {
}
break;
case OPCODE_BINARY:
+ // See https://github.com/gimite/web-socket-js/pull/89
+ // for discussion about supporting binary data.
close(1003, "Received binary data, which is not supported.");
break;
case OPCODE_CLOSE:
@@ -487,6 +491,9 @@ public class WebSocket extends EventDispatcher {
frame.fin = (buffer[0] & 0x80) != 0;
frame.rsv = (buffer[0] & 0x70) >> 4;
frame.opcode = buffer[0] & 0x0f;
+ // Payload unmasking is not implemented because masking frames from server
+ // is not allowed. This field is used only for error checking.
+ frame.mask = (buffer[1] & 0x80) != 0;
plength = buffer[1] & 0x7f;
if (plength == 126) {