2009-09-30 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Oct 2009 01:09:09 +0000 (01:09 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Oct 2009 01:09:09 +0000 (01:09 +0000)
        Reviewed by Brady Eidson.

        307 redirects should pass along http body and Content-Type header
        https://bugs.webkit.org/show_bug.cgi?id=29943

        Follow-up fix for:
        <rdar://problem/3802660> SAP: 307 (Temporary Redirect) responses should use POST, not GET

        Test: http/tests/loading/resources/redirect-methods-result.php

        * platform/network/cf/ResourceHandleCFNet.cpp:
        (WebCore::willSendRequest): Pass along http body and Content-Type header.
        * platform/network/mac/ResourceHandleMac.mm:
        (-[WebCoreResourceHandleAsDelegate connection:willSendRequest:redirectResponse:]): ditto
2009-09-30  Maciej Stachowiak  <mjs@apple.com>

        Reviewed by Brady Eidson.

        307 redirects should pass along http body and Content-Type header
        https://bugs.webkit.org/show_bug.cgi?id=29943

        Follow-up fix for:
        <rdar://problem/3802660> SAP: 307 (Temporary Redirect) responses should use POST, not GET

        * http/tests/loading/redirect-methods.html: Updated test to show the http body and content-type header.
        * http/tests/loading/redirect-methods-expected.txt:
        * http/tests/loading/resources/redirect-methods-result.php:

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

LayoutTests/ChangeLog
LayoutTests/http/tests/loading/redirect-methods-expected.txt
LayoutTests/http/tests/loading/redirect-methods.html
LayoutTests/http/tests/loading/resources/redirect-methods-result.php
WebCore/ChangeLog
WebCore/platform/network/cf/ResourceHandleCFNet.cpp
WebCore/platform/network/mac/ResourceHandleMac.mm

index a97176685cb808f23ac22ed1683b94c40a2533d8..823eafb7502e11830c3237dd893910c26683b201 100644 (file)
@@ -1,3 +1,17 @@
+2009-09-30  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Brady Eidson.
+
+        307 redirects should pass along http body and Content-Type header
+        https://bugs.webkit.org/show_bug.cgi?id=29943
+
+        Follow-up fix for:
+        <rdar://problem/3802660> SAP: 307 (Temporary Redirect) responses should use POST, not GET
+
+        * http/tests/loading/redirect-methods.html: Updated test to show the http body and content-type header.
+        * http/tests/loading/redirect-methods-expected.txt:
+        * http/tests/loading/resources/redirect-methods-result.php: 
+
 2009-09-30  Jeremy Orlow  <jorlow@chromium.org>
 
         Reviewed by Dimitri Glazkov.
index 110fd2db0e9f79f5c942f2c3b19f311d2671dd56..8ada6361af7118f33262cc9d6169a5399845490c 100644 (file)
@@ -117,4 +117,15 @@ frame "3" - didHandleOnloadEventsForFrame
 frame "3" - didFinishLoadForFrame
 This test checks to see what HTTP method is used to fetch the final resource in the case where the first request results in a redirect.
 301, 302, 303, and 307 http redirects are all tested.
+301 redirect
+
+
+302 redirect
+
+
+303 redirect
+
+
+307 redirect
+
 
index d4497b0ccda5141890fc102570086c4266b1cf4d..9430ede91da624749e49596f0f45f514f021d932 100644 (file)
@@ -15,9 +15,13 @@ var testCodes = [301, 302, 303, 307];
 
 function createFrame(index)
 {
+    var h4 = document.createElement("h4");
+    h4.innerHTML = testCodes[index] + " redirect";
+    document.body.appendChild(h4);
     var iframe = document.createElement("iframe");
     iframe.setAttribute("testCode", testCodes[index]);
     iframe.setAttribute("id", index);
+    iframe.setAttribute("height", "90px");
     document.body.appendChild(iframe);
     iframe.src="resources/redirect-methods-form.html";
     iframe.setAttribute("onload", "iframeLoaded(" + index + ");");
index 775ed3050109861d98f7f9d67135deee42517417..c27886b9dfbc3748f27449ffe0cf362a876462ea 100644 (file)
@@ -5,4 +5,6 @@ if ($status > 200 && !$_GET['redirected']) {
   exit();
 }
 ?>
-This page loaded using the <?php echo $_SERVER['REQUEST_METHOD'] ?> method.
+Request Method: <?php echo $_SERVER['REQUEST_METHOD'] ?><br> 
+Request Body: <?php echo @file_get_contents('php://input') ?><br>
+Request Content-Type: <?php echo $_SERVER["CONTENT_TYPE"]; ?>
index edc9450d269ce78d32864c984669818219c4eb75..517d8a8c608e81e9740ea0d127ff073dc5798c05 100644 (file)
@@ -1,3 +1,20 @@
+2009-09-30  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Brady Eidson.
+
+        307 redirects should pass along http body and Content-Type header
+        https://bugs.webkit.org/show_bug.cgi?id=29943
+
+        Follow-up fix for:
+        <rdar://problem/3802660> SAP: 307 (Temporary Redirect) responses should use POST, not GET
+        
+        Test: http/tests/loading/resources/redirect-methods-result.php
+
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::willSendRequest): Pass along http body and Content-Type header.
+        * platform/network/mac/ResourceHandleMac.mm:
+        (-[WebCoreResourceHandleAsDelegate connection:willSendRequest:redirectResponse:]): ditto
+
 2009-09-30  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Mark Rowe.
index cd309a9de4cf054416f5b23c8dda7fa4431e83cb..8261e44f6ae7acc980ed02944866dc1d1626cea7 100644 (file)
@@ -139,6 +139,15 @@ CFURLRequestRef willSendRequest(CFURLConnectionRef conn, CFURLRequestRef cfReque
             if (CFStringCompareWithOptions(originalMethod.get(), newMethod.get(), CFRangeMake(0, CFStringGetLength(originalMethod.get())), kCFCompareCaseInsensitive)) {
                 RetainPtr<CFMutableURLRequestRef> mutableRequest(AdoptCF, CFURLRequestCreateMutableCopy(0, cfRequest));
                 CFURLRequestSetHTTPRequestMethod(mutableRequest.get(), originalMethod.get());
+
+                FormData* body = handle->request().httpBody();
+                if (!equalIgnoringCase(handle->request().httpMethod(), "GET") && body && !body->isEmpty())
+                    WebCore::setHTTPBody(mutableRequest, body);
+
+                String originalContentType = m_handle->request.httpContentType();
+                if (!originalContentType->isEmpty())
+                    CFURLRequestSetHTTPHeaderFieldValue(mutableRequest.get(), CFSTR("Content-Type"), originalContentType);
+
                 request = mutableRequest.get();
             }
         }
index d0cda032e11e41c3c869b5b460a5d8f90f58669a..ec60079b67c8fdb45b221dc9ed74b7e404a088d2 100644 (file)
@@ -605,6 +605,15 @@ void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challen
         if (!equalIgnoringCase(originalMethod, String([newRequest HTTPMethod]))) {
             NSMutableURLRequest *mutableRequest = [newRequest mutableCopy];
             [mutableRequest setHTTPMethod:originalMethod];
+    
+            FormData* body = m_handle->request().httpBody();
+            if (!equalIgnoringCase(originalMethod, "GET") && body && !body->isEmpty())
+                WebCore::setHTTPBody(mutableRequest, body);
+
+            String originalContentType = m_handle->request().httpContentType();
+            if (!originalContentType.isEmpty())
+                [mutableRequest setValue:originalContentType forHTTPHeaderField:@"Content-Type"];
+
             newRequest = [mutableRequest autorelease];
         }
     }