- Revision
- 144037
- Author
- toyos...@chromium.org
- Date
- 2013-02-26 04:01:24 -0800 (Tue, 26 Feb 2013)
Log Message
Add User-Agent header in opening handshake headers.
https://bugs.webkit.org/show_bug.cgi?id=110601
Reviewed by Alexey Proskuryakov.
RFC-6455 doesn't require to send User-Agent header, but allow it.
Many web application developers want to have it, and Firefox already
did it. This patch adds User-Agent header in opening handshake also in
WebKit ports.
Test: http/tests/websocket/tests/hybi/useragent-in-openinghandshake.html
Source/WebCore:
* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::clientHandshakeMessage):
(WebCore::WebSocketHandshake::clientHandshakeRequest):
LayoutTests:
* http/tests/websocket/tests/hybi/sendback_ua_wsh.py: Added.
(web_socket_do_extra_handshake):
(web_socket_transfer_data):
* http/tests/websocket/tests/hybi/useragent-in-openinghandshake-expected.txt: Added.
* http/tests/websocket/tests/hybi/useragent-in-openinghandshake.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (144036 => 144037)
--- trunk/LayoutTests/ChangeLog 2013-02-26 11:41:23 UTC (rev 144036)
+++ trunk/LayoutTests/ChangeLog 2013-02-26 12:01:24 UTC (rev 144037)
@@ -1,3 +1,23 @@
+2013-02-26 Takashi Toyoshima <toyos...@chromium.org>
+
+ Add User-Agent header in opening handshake headers.
+ https://bugs.webkit.org/show_bug.cgi?id=110601
+
+ Reviewed by Alexey Proskuryakov.
+
+ RFC-6455 doesn't require to send User-Agent header, but allow it.
+ Many web application developers want to have it, and Firefox already
+ did it. This patch adds User-Agent header in opening handshake also in
+ WebKit ports.
+
+ Test: http/tests/websocket/tests/hybi/useragent-in-openinghandshake.html
+
+ * http/tests/websocket/tests/hybi/sendback_ua_wsh.py: Added.
+ (web_socket_do_extra_handshake):
+ (web_socket_transfer_data):
+ * http/tests/websocket/tests/hybi/useragent-in-openinghandshake-expected.txt: Added.
+ * http/tests/websocket/tests/hybi/useragent-in-openinghandshake.html: Added.
+
2013-02-26 Zan Dobersek <zdober...@igalia.com>
Unreviewed GTK gardening.
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/sendback_ua_wsh.py (0 => 144037)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/sendback_ua_wsh.py (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/sendback_ua_wsh.py 2013-02-26 12:01:24 UTC (rev 144037)
@@ -0,0 +1,38 @@
+# Copyright 2013, Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+def web_socket_do_extra_handshake(request):
+ pass # Always accept.
+
+
+def web_socket_transfer_data(request):
+ ua = request.headers_in.get('User-Agent')
+ if ua is None:
+ ua = 'opening handshake doesn\'t contain User-Agent header'
+ request.ws_stream.send_message(ua, binary=False)
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/useragent-in-openinghandshake-expected.txt (0 => 144037)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/useragent-in-openinghandshake-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/useragent-in-openinghandshake-expected.txt 2013-02-26 12:01:24 UTC (rev 144037)
@@ -0,0 +1,9 @@
+Web Socket test to check if opening handshake contains User-Agent header
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS event.data is navigator.userAgent
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/useragent-in-openinghandshake.html (0 => 144037)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/useragent-in-openinghandshake.html (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/useragent-in-openinghandshake.html 2013-02-26 12:01:24 UTC (rev 144037)
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script type="text/_javascript_">
+description("Web Socket test to check if opening handshake contains User-Agent header");
+
+window.jsTestIsAsync = true;
+
+function endTest()
+{
+ clearTimeout(timeoutID);
+ finishJSTest();
+}
+
+var ws = new WebSocket("ws://localhost:8880/websocket/tests/hybi/sendback_ua");
+
+ws._onmessage_ = function(messageEvent)
+{
+ // The server should echo back the User-Agent header value.
+ event = messageEvent;
+ shouldBe("event.data", "navigator.userAgent");
+ finishJSTest();
+};
+
+function timeOutCallback()
+{
+ testFailed("Timed out in state: " + ws.readyState);
+ endTest();
+}
+
+var timeoutID = setTimeout(timeOutCallback, 3000);
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (144036 => 144037)
--- trunk/Source/WebCore/ChangeLog 2013-02-26 11:41:23 UTC (rev 144036)
+++ trunk/Source/WebCore/ChangeLog 2013-02-26 12:01:24 UTC (rev 144037)
@@ -1,3 +1,21 @@
+2013-02-26 Takashi Toyoshima <toyos...@chromium.org>
+
+ Add User-Agent header in opening handshake headers.
+ https://bugs.webkit.org/show_bug.cgi?id=110601
+
+ Reviewed by Alexey Proskuryakov.
+
+ RFC-6455 doesn't require to send User-Agent header, but allow it.
+ Many web application developers want to have it, and Firefox already
+ did it. This patch adds User-Agent header in opening handshake also in
+ WebKit ports.
+
+ Test: http/tests/websocket/tests/hybi/useragent-in-openinghandshake.html
+
+ * Modules/websockets/WebSocketHandshake.cpp:
+ (WebCore::WebSocketHandshake::clientHandshakeMessage):
+ (WebCore::WebSocketHandshake::clientHandshakeRequest):
+
2013-02-26 Mike West <mk...@chromium.org>
XSSAuditor: Don't rely on implicit casting when copying the document's KURL to String.
Modified: trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp (144036 => 144037)
--- trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp 2013-02-26 11:41:23 UTC (rev 144036)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp 2013-02-26 12:01:24 UTC (rev 144037)
@@ -219,6 +219,9 @@
if (extensionValue.length())
fields.append("Sec-WebSocket-Extensions: " + extensionValue);
+ // Add a User-Agent header.
+ fields.append("User-Agent: " + m_context->userAgent(m_context->url()));
+
// Fields in the handshake are sent by the client in a random order; the
// order is not meaningful. Thus, it's ok to send the order we constructed
// the fields.
@@ -264,6 +267,9 @@
if (extensionValue.length())
request->addHeaderField("Sec-WebSocket-Extensions", extensionValue);
+ // Add a User-Agent header.
+ request->addHeaderField("User-Agent", m_context->userAgent(m_context->url()));
+
return request.release();
}