2009-12-02 Fumitoshi Ukai <ukai@chromium.org>
authorukai@chromium.org <ukai@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Dec 2009 08:19:47 +0000 (08:19 +0000)
committerukai@chromium.org <ukai@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Dec 2009 08:19:47 +0000 (08:19 +0000)
        Reviewed by Alexey Proskuryakov.

        WebSocket handshake check query component of URL
        https://bugs.webkit.org/show_bug.cgi?id=31617

        * websocket/tests/echo-location_wsh.py: Added.
        * websocket/tests/no-query_wsh.py: Added.
        * websocket/tests/script-tests/url-with-credential.js: Added.
        * websocket/tests/script-tests/url-with-empty-query.js: Added.
        * websocket/tests/script-tests/url-with-fragment.js: Added.
        * websocket/tests/script-tests/url-with-query-for-no-query.js: Added.
        * websocket/tests/script-tests/url-with-query.js: Added.
        * websocket/tests/url-with-credential-expected.txt: Added.
        * websocket/tests/url-with-credential.html: Added.
        * websocket/tests/url-with-empty-query-expected.txt: Added.
        * websocket/tests/url-with-empty-query.html: Added.
        * websocket/tests/url-with-fragment-expected.txt: Added.
        * websocket/tests/url-with-fragment.html: Added.
        * websocket/tests/url-with-query-expected.txt: Added.
        * websocket/tests/url-with-query-for-no-query-expected.txt: Added.
        * websocket/tests/url-with-query-for-no-query.html: Added.
        * websocket/tests/url-with-query.html: Added.
2009-12-02  Fumitoshi Ukai  <ukai@chromium.org>

        Reviewed by Alexey Proskuryakov.

        WebSocket handshake check query component of URL
        https://bugs.webkit.org/show_bug.cgi?id=31617

        Tests: websocket/tests/url-with-credential.html
               websocket/tests/url-with-empty-query.html
               websocket/tests/url-with-fragment.html
               websocket/tests/url-with-query-for-no-query.html
               websocket/tests/url-with-query.html

        * platform/KURLGoogle.cpp:
        (WebCore::KURL::query): returns a null if query is not specified and returns an empty if query is specified but empty.
        * websockets/WebSocketHandshake.cpp:
        (WebCore::resourceName): added. add query component to path if specified.
        (WebCore::WebSocketHandshake::clientLocation):
        (WebCore::WebSocketHandshake::clientHandshakeMessage):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51589 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
LayoutTests/ChangeLog
LayoutTests/websocket/tests/echo-location_wsh.py [new file with mode: 0644]
LayoutTests/websocket/tests/no-query_wsh.py [new file with mode: 0644]
LayoutTests/websocket/tests/script-tests/url-with-credential.js [new file with mode: 0644]
LayoutTests/websocket/tests/script-tests/url-with-empty-query.js [new file with mode: 0644]
LayoutTests/websocket/tests/script-tests/url-with-fragment.js [new file with mode: 0644]
LayoutTests/websocket/tests/script-tests/url-with-query-for-no-query.js [new file with mode: 0644]
LayoutTests/websocket/tests/script-tests/url-with-query.js [new file with mode: 0644]
LayoutTests/websocket/tests/url-with-credential-expected.txt [new file with mode: 0644]
LayoutTests/websocket/tests/url-with-credential.html [new file with mode: 0644]
LayoutTests/websocket/tests/url-with-empty-query-expected.txt [new file with mode: 0644]
LayoutTests/websocket/tests/url-with-empty-query.html [new file with mode: 0644]
LayoutTests/websocket/tests/url-with-fragment-expected.txt [new file with mode: 0644]
LayoutTests/websocket/tests/url-with-fragment.html [new file with mode: 0644]
LayoutTests/websocket/tests/url-with-query-expected.txt [new file with mode: 0644]
LayoutTests/websocket/tests/url-with-query-for-no-query-expected.txt [new file with mode: 0644]
LayoutTests/websocket/tests/url-with-query-for-no-query.html [new file with mode: 0644]
LayoutTests/websocket/tests/url-with-query.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/platform/KURLGoogle.cpp
WebCore/websockets/WebSocketHandshake.cpp

index 613acd9..e8bf90f 100644 (file)
@@ -1,3 +1,28 @@
+2009-12-02  Fumitoshi Ukai  <ukai@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        WebSocket handshake check query component of URL
+        https://bugs.webkit.org/show_bug.cgi?id=31617
+
+        * websocket/tests/echo-location_wsh.py: Added.
+        * websocket/tests/no-query_wsh.py: Added.
+        * websocket/tests/script-tests/url-with-credential.js: Added.
+        * websocket/tests/script-tests/url-with-empty-query.js: Added.
+        * websocket/tests/script-tests/url-with-fragment.js: Added.
+        * websocket/tests/script-tests/url-with-query-for-no-query.js: Added.
+        * websocket/tests/script-tests/url-with-query.js: Added.
+        * websocket/tests/url-with-credential-expected.txt: Added.
+        * websocket/tests/url-with-credential.html: Added.
+        * websocket/tests/url-with-empty-query-expected.txt: Added.
+        * websocket/tests/url-with-empty-query.html: Added.
+        * websocket/tests/url-with-fragment-expected.txt: Added.
+        * websocket/tests/url-with-fragment.html: Added.
+        * websocket/tests/url-with-query-expected.txt: Added.
+        * websocket/tests/url-with-query-for-no-query-expected.txt: Added.
+        * websocket/tests/url-with-query-for-no-query.html: Added.
+        * websocket/tests/url-with-query.html: Added.
+
 2009-12-01  Shinichiro Hamaji  <hamaji@chromium.org>
 
         Reviewed by Eric Seidel.
diff --git a/LayoutTests/websocket/tests/echo-location_wsh.py b/LayoutTests/websocket/tests/echo-location_wsh.py
new file mode 100644 (file)
index 0000000..3390570
--- /dev/null
@@ -0,0 +1,39 @@
+# Copyright (C) 2009 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.
+
+
+from mod_pywebsocket import msgutil
+
+
+def web_socket_do_extra_handshake(request):
+    pass
+
+
+def web_socket_transfer_data(request):
+    print request.ws_location
+    msgutil.send_message(request, request.ws_location)
diff --git a/LayoutTests/websocket/tests/no-query_wsh.py b/LayoutTests/websocket/tests/no-query_wsh.py
new file mode 100644 (file)
index 0000000..2b79615
--- /dev/null
@@ -0,0 +1,38 @@
+# Copyright (C) 2009 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.
+
+
+from mod_pywebsocket import msgutil
+
+
+def web_socket_do_extra_handshake(request):
+    request.ws_location = request.ws_resource.split('?', 1)[0]
+
+
+def web_socket_transfer_data(request):
+    msgutil.send_message(request, request.ws_location)
diff --git a/LayoutTests/websocket/tests/script-tests/url-with-credential.js b/LayoutTests/websocket/tests/script-tests/url-with-credential.js
new file mode 100644 (file)
index 0000000..b4b7235
--- /dev/null
@@ -0,0 +1,37 @@
+description("Make sure handshake with URL with credentail info success.");
+
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+var url = "ws://user:pass@127.0.0.1:8880/websocket/tests/echo-location";
+var handshake_success = false;
+var ws_location;
+
+function endTest()
+{
+    clearTimeout(timeoutID);
+    shouldBeTrue("handshake_success");
+    shouldBe("ws_location", '"ws://127.0.0.1:8880/websocket/tests/echo-location"');
+    isSuccessfullyParsed();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+debug("url=" + url);
+var ws = new WebSocket(url);
+ws.onopen = function () {
+    debug("WebSocket is open");
+    handshake_success = true;
+};
+ws.onmessage = function (evt) {
+    ws_location = evt.data;
+    debug("received:" + ws_location);
+    ws.close();
+};
+ws.onclose = function () {
+    debug("WebSocket is closed");
+    endTest();
+};
+var timeoutID = setTimeout("endTest()", 2000);
+
+var successfullyParsed = true;
diff --git a/LayoutTests/websocket/tests/script-tests/url-with-empty-query.js b/LayoutTests/websocket/tests/script-tests/url-with-empty-query.js
new file mode 100644 (file)
index 0000000..0b478b6
--- /dev/null
@@ -0,0 +1,37 @@
+description("Make sure handshake with URL with empty query components success.");
+
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+var url = "ws://127.0.0.1:8880/websocket/tests/echo-location?";
+var handshake_success = false;
+var ws_location;
+
+function endTest()
+{
+    clearTimeout(timeoutID);
+    shouldBeTrue("handshake_success");
+    shouldBe("ws_location", "url");
+    isSuccessfullyParsed();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+debug("url=" + url);
+var ws = new WebSocket(url);
+ws.onopen = function () {
+    debug("WebSocket is open");
+    handshake_success = true;
+};
+ws.onmessage = function (evt) {
+    ws_location = evt.data;
+    debug("received:" + ws_location);
+    ws.close();
+};
+ws.onclose = function () {
+    debug("WebSocket is closed");
+    endTest();
+};
+var timeoutID = setTimeout("endTest()", 2000);
+
+var successfullyParsed = true;
diff --git a/LayoutTests/websocket/tests/script-tests/url-with-fragment.js b/LayoutTests/websocket/tests/script-tests/url-with-fragment.js
new file mode 100644 (file)
index 0000000..73e8a01
--- /dev/null
@@ -0,0 +1,37 @@
+description("Make sure handshake with URL with fragment components success.");
+
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+var url = "ws://127.0.0.1:8880/websocket/tests/echo-location#fragment";
+var handshake_success = false;
+var ws_location;
+
+function endTest()
+{
+    clearTimeout(timeoutID);
+    shouldBeTrue("handshake_success");
+    shouldBe("ws_location", '"ws://127.0.0.1:8880/websocket/tests/echo-location"');
+    isSuccessfullyParsed();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+debug("url=" + url);
+var ws = new WebSocket(url);
+ws.onopen = function () {
+    debug("WebSocket is open");
+    handshake_success = true;
+};
+ws.onmessage = function (evt) {
+    ws_location = evt.data;
+    debug("received:" + ws_location);
+    ws.close();
+};
+ws.onclose = function () {
+    debug("WebSocket is closed");
+    endTest();
+};
+var timeoutID = setTimeout("endTest()", 2000);
+
+var successfullyParsed = true;
diff --git a/LayoutTests/websocket/tests/script-tests/url-with-query-for-no-query.js b/LayoutTests/websocket/tests/script-tests/url-with-query-for-no-query.js
new file mode 100644 (file)
index 0000000..d1d112b
--- /dev/null
@@ -0,0 +1,37 @@
+description("Make sure handshake with URL with query components fails against server that doesn't support query component.");
+
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+var url = "ws://127.0.0.1:8880/websocket/tests/no-query-support?";
+var handshake_success = false;
+var ws_location;
+
+function endTest()
+{
+    clearTimeout(timeoutID);
+    shouldBeFalse("handshake_success");
+    shouldBeUndefined("ws_location");
+    isSuccessfullyParsed();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+debug("url=" + url);
+var ws = new WebSocket(url);
+ws.onopen = function () {
+    debug("WebSocket is open");
+    handshake_success = true;
+};
+ws.onmessge = function (evt) {
+    ws_location = evt.data;
+    debug("received:" + ws_location);
+    ws.close();
+};
+ws.onclose = function () {
+    debug("WebSocket is closed");
+    endTest();
+};
+var timeoutID = setTimeout("endTest()", 2000);
+
+var successfullyParsed = true;
diff --git a/LayoutTests/websocket/tests/script-tests/url-with-query.js b/LayoutTests/websocket/tests/script-tests/url-with-query.js
new file mode 100644 (file)
index 0000000..618628b
--- /dev/null
@@ -0,0 +1,37 @@
+description("Make sure handshake with URL with query components success.");
+
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+var url = "ws://127.0.0.1:8880/websocket/tests/echo-location?q=v";
+var handshake_success = false;
+var ws_location;
+
+function endTest()
+{
+    clearTimeout(timeoutID);
+    shouldBeTrue("handshake_success");
+    shouldBe("ws_location", "url");
+    isSuccessfullyParsed();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+debug("url=" + url);
+var ws = new WebSocket(url);
+ws.onopen = function () {
+    debug("WebSocket is open");
+    handshake_success = true;
+};
+ws.onmessage = function (evt) {
+    ws_location = evt.data;
+    debug("received:" + ws_location);
+    ws.close();
+};
+ws.onclose = function () {
+    debug("WebSocket is closed");
+    endTest();
+};
+var timeoutID = setTimeout("endTest()", 2000);
+
+var successfullyParsed = true;
diff --git a/LayoutTests/websocket/tests/url-with-credential-expected.txt b/LayoutTests/websocket/tests/url-with-credential-expected.txt
new file mode 100644 (file)
index 0000000..da79d52
--- /dev/null
@@ -0,0 +1,14 @@
+Make sure handshake with URL with credentail info success.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+url=ws://user:pass@127.0.0.1:8880/websocket/tests/echo-location
+WebSocket is open
+received:ws://127.0.0.1:8880/websocket/tests/echo-location
+WebSocket is closed
+PASS handshake_success is true
+PASS ws_location is "ws://127.0.0.1:8880/websocket/tests/echo-location"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/websocket/tests/url-with-credential.html b/LayoutTests/websocket/tests/url-with-credential.html
new file mode 100644 (file)
index 0000000..7ac556a
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script src="script-tests/url-with-credential.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/websocket/tests/url-with-empty-query-expected.txt b/LayoutTests/websocket/tests/url-with-empty-query-expected.txt
new file mode 100644 (file)
index 0000000..f2cb9e3
--- /dev/null
@@ -0,0 +1,14 @@
+Make sure handshake with URL with empty query components success.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+url=ws://127.0.0.1:8880/websocket/tests/echo-location?
+WebSocket is open
+received:ws://127.0.0.1:8880/websocket/tests/echo-location?
+WebSocket is closed
+PASS handshake_success is true
+PASS ws_location is url
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/websocket/tests/url-with-empty-query.html b/LayoutTests/websocket/tests/url-with-empty-query.html
new file mode 100644 (file)
index 0000000..227f0b3
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script src="script-tests/url-with-empty-query.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/websocket/tests/url-with-fragment-expected.txt b/LayoutTests/websocket/tests/url-with-fragment-expected.txt
new file mode 100644 (file)
index 0000000..27c764f
--- /dev/null
@@ -0,0 +1,14 @@
+Make sure handshake with URL with fragment components success.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+url=ws://127.0.0.1:8880/websocket/tests/echo-location#fragment
+WebSocket is open
+received:ws://127.0.0.1:8880/websocket/tests/echo-location
+WebSocket is closed
+PASS handshake_success is true
+PASS ws_location is "ws://127.0.0.1:8880/websocket/tests/echo-location"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/websocket/tests/url-with-fragment.html b/LayoutTests/websocket/tests/url-with-fragment.html
new file mode 100644 (file)
index 0000000..2b34770
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script src="script-tests/url-with-fragment.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/websocket/tests/url-with-query-expected.txt b/LayoutTests/websocket/tests/url-with-query-expected.txt
new file mode 100644 (file)
index 0000000..49e7c28
--- /dev/null
@@ -0,0 +1,14 @@
+Make sure handshake with URL with query components success.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+url=ws://127.0.0.1:8880/websocket/tests/echo-location?q=v
+WebSocket is open
+received:ws://127.0.0.1:8880/websocket/tests/echo-location?q=v
+WebSocket is closed
+PASS handshake_success is true
+PASS ws_location is url
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/websocket/tests/url-with-query-for-no-query-expected.txt b/LayoutTests/websocket/tests/url-with-query-for-no-query-expected.txt
new file mode 100644 (file)
index 0000000..39af77c
--- /dev/null
@@ -0,0 +1,12 @@
+Make sure handshake with URL with query components fails against server that doesn't support query component.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+url=ws://127.0.0.1:8880/websocket/tests/no-query-support?
+WebSocket is closed
+PASS handshake_success is false
+PASS ws_location is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/websocket/tests/url-with-query-for-no-query.html b/LayoutTests/websocket/tests/url-with-query-for-no-query.html
new file mode 100644 (file)
index 0000000..7b0fc39
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script src="script-tests/url-with-query-for-no-query.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/websocket/tests/url-with-query.html b/LayoutTests/websocket/tests/url-with-query.html
new file mode 100644 (file)
index 0000000..ac90502
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script src="script-tests/url-with-query.js"></script>
+</body>
+</html>
index 78a5700..4bbfb9a 100644 (file)
@@ -1,3 +1,23 @@
+2009-12-02  Fumitoshi Ukai  <ukai@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        WebSocket handshake check query component of URL
+        https://bugs.webkit.org/show_bug.cgi?id=31617
+
+        Tests: websocket/tests/url-with-credential.html
+               websocket/tests/url-with-empty-query.html
+               websocket/tests/url-with-fragment.html
+               websocket/tests/url-with-query-for-no-query.html
+               websocket/tests/url-with-query.html
+
+        * platform/KURLGoogle.cpp:
+        (WebCore::KURL::query): returns a null if query is not specified and returns an empty if query is specified but empty.
+        * websockets/WebSocketHandshake.cpp:
+        (WebCore::resourceName): added. add query component to path if specified.
+        (WebCore::WebSocketHandshake::clientLocation):
+        (WebCore::WebSocketHandshake::clientHandshakeMessage):
+
 2009-12-01  David Levin  <levin@chromium.org>
 
         Reviewed by Eric Seidel.
index 763bf3b..5604883 100644 (file)
@@ -552,7 +552,10 @@ String KURL::query() const
     // Bug: https://bugs.webkit.org/show_bug.cgi?id=21015 this function returns
     // an empty string when the query is empty rather than a null (not sure
     // which is right).
-    return String("", 0);
+    // Returns a null if the query is not specified, instead of empty.
+    if (m_url.m_parsed.query.is_valid())
+        return String("", 0);
+    return String();
 }
 
 String KURL::path() const
index 691fa1c..d1da443 100644 (file)
@@ -74,6 +74,13 @@ static String extractResponseCode(const char* header, int len)
     return String(space1 + 1, space2 - space1 - 1);
 }
 
+static String resourceName(const KURL& url)
+{
+    if (url.query().isNull())
+        return url.path();
+    return url.path() + "?" + url.query();
+}
+
 WebSocketHandshake::WebSocketHandshake(const KURL& url, const String& protocol, ScriptExecutionContext* context)
     : m_url(url)
     , m_clientProtocol(protocol)
@@ -139,7 +146,7 @@ String WebSocketHandshake::clientLocation() const
             builder.append(String::number(m_url.port()));
         }
     }
-    builder.append(m_url.path());
+    builder.append(resourceName(m_url));
     return builder.toString();
 }
 
@@ -148,11 +155,7 @@ CString WebSocketHandshake::clientHandshakeMessage() const
     StringBuilder builder;
 
     builder.append("GET ");
-    builder.append(m_url.path());
-    if (!m_url.query().isEmpty()) {
-        builder.append("?");
-        builder.append(m_url.query());
-    }
+    builder.append(resourceName(m_url));
     builder.append(" HTTP/1.1\r\n");
     builder.append("Upgrade: WebSocket\r\n");
     builder.append("Connection: Upgrade\r\n");