Title: [147914] trunk
Revision
147914
Author
[email protected]
Date
2013-04-08 08:26:39 -0700 (Mon, 08 Apr 2013)

Log Message

[GTK][EFL] HEAD requests changed to GET after 303 redirection
https://bugs.webkit.org/show_bug.cgi?id=110127

Patch by Youenn Fablet <[email protected]> on 2013-04-08
Reviewed by Martin Robinson.

Source/WebCore:

Made shouldRedirectAsGET always return false for HEAD requests.

* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::shouldRedirectAsGET):

LayoutTests:

Added tests checking HEAD redirection.
Redirected HEAD requests are expected to remain HEAD requests.
(http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-21#section-7.4)

* http/tests/xmlhttprequest/head-redirection-expected.txt: Added.
* http/tests/xmlhttprequest/head-redirection.html: Added.
* http/tests/xmlhttprequest/resources/get_method.php: Added.
* http/tests/xmlhttprequest/resources/redirect_methods.php: Added.
* platform/mac/http/tests/xmlhttprequest/head-redirection-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (147913 => 147914)


--- trunk/LayoutTests/ChangeLog	2013-04-08 14:49:47 UTC (rev 147913)
+++ trunk/LayoutTests/ChangeLog	2013-04-08 15:26:39 UTC (rev 147914)
@@ -1,3 +1,20 @@
+2013-04-08  Youenn Fablet  <[email protected]>
+
+        [GTK][EFL] HEAD requests changed to GET after 303 redirection
+        https://bugs.webkit.org/show_bug.cgi?id=110127
+
+        Reviewed by Martin Robinson.
+
+        Added tests checking HEAD redirection.
+        Redirected HEAD requests are expected to remain HEAD requests.
+        (http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-21#section-7.4)
+
+        * http/tests/xmlhttprequest/head-redirection-expected.txt: Added.
+        * http/tests/xmlhttprequest/head-redirection.html: Added.
+        * http/tests/xmlhttprequest/resources/get_method.php: Added.
+        * http/tests/xmlhttprequest/resources/redirect_methods.php: Added.
+        * platform/mac/http/tests/xmlhttprequest/head-redirection-expected.txt: Added.
+
 2013-04-08  Christophe Dumez  <[email protected]>
 
         Unreviewed EFL gardening.

Added: trunk/LayoutTests/http/tests/xmlhttprequest/head-redirection-expected.txt (0 => 147914)


--- trunk/LayoutTests/http/tests/xmlhttprequest/head-redirection-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/head-redirection-expected.txt	2013-04-08 15:26:39 UTC (rev 147914)
@@ -0,0 +1,10 @@
+This page tests redirection of HEAD requests with different codes (301, 302, 303, 307). 
+As described in http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics (in particular sections 7.4.2, 7.4.3, 7.4.4 and 7.4.7 as of version 22 of the document), a redirected HEAD request is expected to remain a HEAD request. 
+
+This test loads a web page that does a XHR HEAD request to a first script. This script does a redirection to a second script that sends a response containing the request method as a HTTP header.
+
+HEAD-301 - expected HEAD and received HEAD
+HEAD-302 - expected HEAD and received HEAD
+HEAD-303 - expected HEAD and received HEAD
+HEAD-307 - expected HEAD and received HEAD
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/head-redirection.html (0 => 147914)


--- trunk/LayoutTests/http/tests/xmlhttprequest/head-redirection.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/head-redirection.html	2013-04-08 15:26:39 UTC (rev 147914)
@@ -0,0 +1,66 @@
+<html>
+<body>
+<p>
+This page tests redirection of HEAD requests with different codes (301, 302, 303, 307).
+<br/>
+As described in http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics (in particular sections 7.4.2, 7.4.3, 7.4.4 and 7.4.7 as of version 22 of the document), a redirected HEAD request is expected to remain a HEAD request.
+<br/>
+<br/>
+This test loads a web page that does a XHR HEAD request to a first script.
+This script does a redirection to a second script that sends a response containing the request method as a HTTP header.
+</p>
+<pre id="console"></pre>
+  <script type="text/_javascript_">
+    function log(message) {
+       document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
+    }
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    var testIndex = 0;
+    var tests = [
+        {testName : "HEAD-301", method : "HEAD", code : 301, expectedMethod : "HEAD"},
+        {testName : "HEAD-302", method : "HEAD", code : 302, expectedMethod : "HEAD"},
+        {testName : "HEAD-303", method : "HEAD", code : 303, expectedMethod : "HEAD"},
+        {testName : "HEAD-307", method : "HEAD", code : 307, expectedMethod : "HEAD"},
+    ];
+
+    function checkResult(xhr, hasError) {
+        var test = tests[testIndex];
+        if (xhr.status != 200 && xhr.status != 304)
+            hasError = true;
+        var msg = test.testName;
+        if (hasError) {
+            msg += " - error";
+        } else {
+            var requestMethod = xhr.getResponseHeader("REQMETHOD");
+            msg += " - expected " + test.expectedMethod + " and received " + requestMethod;
+        }
+        log(msg);
+
+        if (++testIndex < tests.length) {
+            testMethodSync();
+        } else if (window.testRunner) {
+            testRunner.notifyDone();
+        }
+    }
+
+    var urlTemplate = "/xmlhttprequest/resources/redirect_methods.php?url=""
+
+    function testMethodSync() {
+        var test = tests[testIndex];
+        try {
+            xhr = new XMLHttpRequest;
+            xhr.open(test.method, urlTemplate + test.code, false);
+            xhr.send("");
+            checkResult(xhr, false);
+        } catch(e) {
+            checkResult(xhr, true);
+        }
+    }
+    testMethodSync();
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/xmlhttprequest/resources/get_method.php (0 => 147914)


--- trunk/LayoutTests/http/tests/xmlhttprequest/resources/get_method.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resources/get_method.php	2013-04-08 15:26:39 UTC (rev 147914)
@@ -0,0 +1,7 @@
+<?php
+    $method = $_SERVER['REQUEST_METHOD'];
+    header("REQMETHOD: $method");
+    if ($method != "HEAD") {
+      echo $method;
+    }
+?>

Added: trunk/LayoutTests/http/tests/xmlhttprequest/resources/redirect_methods.php (0 => 147914)


--- trunk/LayoutTests/http/tests/xmlhttprequest/resources/redirect_methods.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resources/redirect_methods.php	2013-04-08 15:26:39 UTC (rev 147914)
@@ -0,0 +1,6 @@
+<?php
+    $url = ""
+    $code = $_GET['code'];
+    header("HTTP/1.1 $code");
+    header("Location: $url");
+?>

Added: trunk/LayoutTests/platform/mac/http/tests/xmlhttprequest/head-redirection-expected.txt (0 => 147914)


--- trunk/LayoutTests/platform/mac/http/tests/xmlhttprequest/head-redirection-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/http/tests/xmlhttprequest/head-redirection-expected.txt	2013-04-08 15:26:39 UTC (rev 147914)
@@ -0,0 +1,10 @@
+This page tests redirection of HEAD requests with different codes (301, 302, 303, 307). 
+As described in http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics (in particular sections 7.4.2, 7.4.3, 7.4.4 and 7.4.7 as of version 22 of the document), a redirected HEAD request is expected to remain a HEAD request. 
+
+This test loads a web page that does a XHR HEAD request to a first script. This script does a redirection to a second script that sends a response containing the request method as a HTTP header.
+
+HEAD-301 - expected HEAD and received GET
+HEAD-302 - expected HEAD and received GET
+HEAD-303 - expected HEAD and received GET
+HEAD-307 - expected HEAD and received HEAD
+

Modified: trunk/Source/WebCore/ChangeLog (147913 => 147914)


--- trunk/Source/WebCore/ChangeLog	2013-04-08 14:49:47 UTC (rev 147913)
+++ trunk/Source/WebCore/ChangeLog	2013-04-08 15:26:39 UTC (rev 147914)
@@ -1,3 +1,15 @@
+2013-04-08  Youenn Fablet  <[email protected]>
+
+        [GTK][EFL] HEAD requests changed to GET after 303 redirection
+        https://bugs.webkit.org/show_bug.cgi?id=110127
+
+        Reviewed by Martin Robinson.
+
+        Made shouldRedirectAsGET always return false for HEAD requests.
+
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::shouldRedirectAsGET):
+
 2013-04-08  Carlos Garcia Campos  <[email protected]>
 
         DragImage should not depend on Frame and CachedImage

Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (147913 => 147914)


--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2013-04-08 14:49:47 UTC (rev 147913)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2013-04-08 15:26:39 UTC (rev 147914)
@@ -419,7 +419,7 @@
 
 static bool shouldRedirectAsGET(SoupMessage* message, KURL& newURL, bool crossOrigin)
 {
-    if (message->method == SOUP_METHOD_GET)
+    if (message->method == SOUP_METHOD_GET || message->method == SOUP_METHOD_HEAD)
         return false;
 
     if (!newURL.protocolIsInHTTPFamily())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to