Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing a bug that it is case sensitive for some header keys/values wh…

…ere it must not be.
  • Loading branch information...
commit 1d0df76b4da4ba4071879e435a4de3512fd3853e 1 parent 29e7ed3
@gimite gimite authored
Showing with 10 additions and 8 deletions.
  1. BIN  WebSocketMain.swf
  2. +10 −8 flash-src/WebSocket.as
View
BIN  WebSocketMain.swf
Binary file not shown
View
18 flash-src/WebSocket.as
@@ -309,6 +309,7 @@ public class WebSocket extends EventDispatcher {
return false;
}
var header:Object = {};
+ var lowerHeader:Object = {};
for (var i:int = 1; i < lines.length; ++i) {
if (lines[i].length == 0) continue;
var m:Array = lines[i].match(/^(\S+): (.*)$/);
@@ -316,18 +317,19 @@ public class WebSocket extends EventDispatcher {
onError("failed to parse response header line: " + lines[i]);
return false;
}
- header[m[1]] = m[2];
+ header[m[1].toLowerCase()] = m[2];
+ lowerHeader[m[1].toLowerCase()] = m[2].toLowerCase();
}
- if (header["Upgrade"] != "WebSocket") {
+ if (lowerHeader["upgrade"] != "websocket") {
onError("invalid Upgrade: " + header["Upgrade"]);
return false;
}
- if (header["Connection"] != "Upgrade") {
+ if (lowerHeader["connection"] != "upgrade") {
onError("invalid Connection: " + header["Connection"]);
return false;
}
- if (!header["Sec-WebSocket-Origin"]) {
- if (header["WebSocket-Origin"]) {
+ if (!lowerHeader["sec-websocket-origin"]) {
+ if (lowerHeader["websocket-origin"]) {
onError(
"The WebSocket server speaks old WebSocket protocol, " +
"which is not supported by web-socket-js. " +
@@ -338,14 +340,14 @@ public class WebSocket extends EventDispatcher {
}
return false;
}
- var resOrigin:String = header["Sec-WebSocket-Origin"].toLowerCase();
+ var resOrigin:String = lowerHeader["sec-websocket-origin"];
if (resOrigin != origin) {
onError("origin doesn't match: '" + resOrigin + "' != '" + origin + "'");
return false;
}
- if (protocol && header["Sec-WebSocket-Protocol"] != protocol) {
+ if (protocol && header["sec-websocket-protocol"] != protocol) {
onError("protocol doesn't match: '" +
- header["WebSocket-Protocol"] + "' != '" + protocol + "'");
+ header["websocket-protocol"] + "' != '" + protocol + "'");
return false;
}
return true;
Please sign in to comment.
Something went wrong with that request. Please try again.