https://bugs.webkit.org/show_bug.cgi?id=81655
Patch by Li Yin <li.yin@intel.com> on 2012-03-21
Reviewed by Adam Barth.
Source/WebCore:
Test: http/tests/websocket/tests/hybi/handshake-fail-by-more-accept-header.html
* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::readHTTPHeaders):
LayoutTests:
* http/tests/websocket/tests/hybi/handshake-fail-by-more-accept-header-expected.txt: Added.
* http/tests/websocket/tests/hybi/handshake-fail-by-more-accept-header.html: Added.
* http/tests/websocket/tests/hybi/handshake-fail-by-more-accept-header_wsh.py: Added.
(web_socket_do_extra_handshake):
(web_socket_transfer_data):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111554
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-03-21 Li Yin <li.yin@intel.com>
+
+ [WebSocket]The Sec-WebSocket-Accept MUST NOT appear more than once in an HTTP response
+ https://bugs.webkit.org/show_bug.cgi?id=81655
+
+ Reviewed by Adam Barth.
+
+ * http/tests/websocket/tests/hybi/handshake-fail-by-more-accept-header-expected.txt: Added.
+ * http/tests/websocket/tests/hybi/handshake-fail-by-more-accept-header.html: Added.
+ * http/tests/websocket/tests/hybi/handshake-fail-by-more-accept-header_wsh.py: Added.
+ (web_socket_do_extra_handshake):
+ (web_socket_transfer_data):
+
2012-03-21 Yury Semikhatsky <yurys@chromium.org>
Web Inspector: event listener section doesn't show all event listeners of the element ancestors
--- /dev/null
+CONSOLE MESSAGE: The Sec-WebSocket-Accept header MUST NOT appear more than once in an HTTP response
+Test that WebSocket handshake fails if there are more one Sec-WebSocket-Accept header field in the response.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src="../../../../js-test-resources/js-test-pre.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("Test that WebSocket handshake fails if there are more one Sec-WebSocket-Accept header field in the response.");
+
+window.jsTestIsAsync = true;
+if (window.layoutTestController)
+ layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 0);
+
+function endTest()
+{
+ clearTimeout(timeoutID);
+ finishJSTest();
+}
+
+var url = "ws://localhost:8880/websocket/tests/hybi/handshake-fail-by-more-accept-header";
+var ws = new WebSocket(url);
+
+ws.onopen = function()
+{
+ testFailed("Unexpectedly Connected.");
+};
+
+ws.onmessage = function(messageEvent)
+{
+ testFailed("Unexpectedly Received: '" + messageEvent.data + "'");
+};
+
+ws.onclose = function()
+{
+ endTest();
+};
+
+function timeOutCallback()
+{
+ debug("Timed out in state: " + ws.readyState);
+ endTest();
+}
+
+var timeoutID = setTimeout(timeOutCallback, 3000);
+
+</script>
+<script src="../../../../js-test-resources/js-test-post.js"></script>
+</body>
+</html>
--- /dev/null
+from mod_pywebsocket import handshake
+from mod_pywebsocket.handshake.hybi import compute_accept
+
+
+def web_socket_do_extra_handshake(request):
+ msg = 'HTTP/1.1 101 Switching Protocols\r\n'
+ msg += 'Upgrade: websocket\r\n'
+ msg += 'Connection: Upgrade\r\n'
+ msg += 'Sec-WebSocket-Accept: %s\r\n' % compute_accept(request.headers_in['Sec-WebSocket-Key'])[0]
+ msg += 'Sec-WebSocket-Accept: XXXXthisiswrongXXXX\r\n'
+ msg += '\r\n'
+ request.connection.write(msg)
+ print msg
+ raise handshake.AbortedByUserException('Abort the connection') # Prevents pywebsocket from sending its own handshake message.
+
+
+def web_socket_transfer_data(request):
+ pass
+2012-03-21 Li Yin <li.yin@intel.com>
+
+ [WebSocket]The Sec-WebSocket-Accept MUST NOT appear more than once in an HTTP response
+ https://bugs.webkit.org/show_bug.cgi?id=81655
+
+ Reviewed by Adam Barth.
+
+ Test: http/tests/websocket/tests/hybi/handshake-fail-by-more-accept-header.html
+
+ * Modules/websockets/WebSocketHandshake.cpp:
+ (WebCore::WebSocketHandshake::readHTTPHeaders):
+
2012-03-21 Alexei Filippov <alexeif@chromium.org>
Web Inspector: Speedup heap snapshot loading.
Vector<char> name;
Vector<char> value;
+ bool sawSecWebSocketAcceptHeaderField = false;
for (const char* p = start; p < end; p++) {
name.clear();
value.clear();
m_failureReason = m_extensionDispatcher.failureReason();
return 0;
}
+ } else if (equalIgnoringCase("Sec-WebSocket-Accept", nameStr)) {
+ if (sawSecWebSocketAcceptHeaderField) {
+ m_failureReason = "The Sec-WebSocket-Accept header MUST NOT appear more than once in an HTTP response";
+ return 0;
+ }
+ m_response.addHeaderField(nameStr, valueStr);
+ sawSecWebSocketAcceptHeaderField = true;
} else
m_response.addHeaderField(nameStr, valueStr);
}