Title: [161176] trunk/Source
Revision
161176
Author
[email protected]
Date
2013-12-31 00:28:17 -0800 (Tue, 31 Dec 2013)

Log Message

[SOUP] willSendRequest doesn't work after a redirect
https://bugs.webkit.org/show_bug.cgi?id=126290

Reviewed by Martin Robinson.

Source/WebCore:

The problem is that we are creating the new soup request for the
redirect before calling ResourceHandleClient::willSendRequest() so
that any change made to the request by the client is ignored.

* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::doRedirect): Create the new soup request and soup
message for the redirect after calling willSendRequest() on the
client.

Source/WebKit2:

Add test cases to test send-request signal in case of
redirection.

* UIProcess/API/gtk/tests/TestResources.cpp:
(testWebResourceSendRequest):
(serverCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (161175 => 161176)


--- trunk/Source/WebCore/ChangeLog	2013-12-31 07:39:01 UTC (rev 161175)
+++ trunk/Source/WebCore/ChangeLog	2013-12-31 08:28:17 UTC (rev 161176)
@@ -1,3 +1,19 @@
+2013-12-30  Carlos Garcia Campos  <[email protected]>
+
+        [SOUP] willSendRequest doesn't work after a redirect
+        https://bugs.webkit.org/show_bug.cgi?id=126290
+
+        Reviewed by Martin Robinson.
+
+        The problem is that we are creating the new soup request for the
+        redirect before calling ResourceHandleClient::willSendRequest() so
+        that any change made to the request by the client is ignored.
+
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::doRedirect): Create the new soup request and soup
+        message for the redirect after calling willSendRequest() on the
+        client.
+
 2013-12-30  Andreas Kling  <[email protected]>
 
         InputType should return input renderers wrapped in RenderPtr.

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


--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2013-12-31 07:39:01 UTC (rev 161175)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2013-12-31 08:28:17 UTC (rev 161176)
@@ -502,12 +502,6 @@
     } else
         applyAuthenticationToRequest(handle, newRequest, true);
 
-    cleanupSoupRequestOperation(handle);
-    if (!createSoupRequestAndMessageForHandle(handle, newRequest, true)) {
-        d->client()->cannotShowURL(handle);
-        return;
-    }
-
     // If we sent credentials with this request's URL, we don't want the response to carry them to
     // the WebKit layer. They were only placed in the URL for the benefit of libsoup.
     newRequest.removeCredentials();
@@ -516,6 +510,18 @@
         d->client()->willSendRequestAsync(handle, newRequest, d->m_response);
     else
         d->client()->willSendRequest(handle, newRequest, d->m_response);
+
+    cleanupSoupRequestOperation(handle);
+
+    // willSendRequest might cancel the load.
+    if (handle->cancelledOrClientless())
+        return;
+
+    if (!createSoupRequestAndMessageForHandle(handle, newRequest, true)) {
+        d->client()->cannotShowURL(handle);
+        return;
+    }
+
     handle->sendPendingRequest();
 }
 

Modified: trunk/Source/WebKit2/ChangeLog (161175 => 161176)


--- trunk/Source/WebKit2/ChangeLog	2013-12-31 07:39:01 UTC (rev 161175)
+++ trunk/Source/WebKit2/ChangeLog	2013-12-31 08:28:17 UTC (rev 161176)
@@ -1,3 +1,17 @@
+2013-12-30  Carlos Garcia Campos  <[email protected]>
+
+        [SOUP] willSendRequest doesn't work after a redirect
+        https://bugs.webkit.org/show_bug.cgi?id=126290
+
+        Reviewed by Martin Robinson.
+
+        Add test cases to test send-request signal in case of
+        redirection.
+
+        * UIProcess/API/gtk/tests/TestResources.cpp:
+        (testWebResourceSendRequest):
+        (serverCallback):
+
 2013-12-30  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r161157, r161158, r161160, r161161,

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp (161175 => 161176)


--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp	2013-12-31 07:39:01 UTC (rev 161175)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp	2013-12-31 08:28:17 UTC (rev 161176)
@@ -568,7 +568,10 @@
         if (resource != m_resource)
             return;
 
-        g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, m_expectedNewResourceURI.data());
+        if (redirectResponse)
+            g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, m_expectedNewResourceURIAfterRedirection.data());
+        else
+            g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, m_expectedNewResourceURI.data());
         g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, webkit_web_resource_get_uri(resource));
 
         SingleResourceLoadTest::resourceSentRequest(resource, request, redirectResponse);
@@ -595,8 +598,14 @@
         m_expectedCancelledResourceURI = uri;
     }
 
+    void setExpectedNewResourceURIAfterRedirection(const CString& uri)
+    {
+        m_expectedNewResourceURIAfterRedirection = uri;
+    }
+
     CString m_expectedNewResourceURI;
     CString m_expectedCancelledResourceURI;
+    CString m_expectedNewResourceURIAfterRedirection;
 };
 
 static void testWebResourceSendRequest(SendRequestTest* test, gconstpointer)
@@ -626,6 +635,36 @@
     g_assert_cmpint(events[1], ==, SingleResourceLoadTest::Failed);
     g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Finished);
     events.clear();
+
+    // URI changed after a redirect.
+    test->setExpectedNewResourceURI(kServer->getURIForPath("/redirected.js"));
+    test->setExpectedNewResourceURIAfterRedirection(kServer->getURIForPath("/_javascript_.js"));
+    test->loadURI(kServer->getURIForPath("redirected-_javascript_.html").data());
+    test->waitUntilResourceLoadFinished();
+    g_assert(test->m_resource);
+
+    g_assert_cmpint(events.size(), ==, 6);
+    g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started);
+    g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest);
+    g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Redirected);
+    g_assert_cmpint(events[3], ==, SingleResourceLoadTest::ReceivedResponse);
+    g_assert_cmpint(events[4], ==, SingleResourceLoadTest::ReceivedData);
+    g_assert_cmpint(events[5], ==, SingleResourceLoadTest::Finished);
+    events.clear();
+
+    // Cancel after a redirect.
+    test->setExpectedNewResourceURI(kServer->getURIForPath("/redirected-to-cancel.js"));
+    test->setExpectedCancelledResourceURI(kServer->getURIForPath("/redirected-to-cancel.js"));
+    test->loadURI(kServer->getURIForPath("/redirected-to-cancel.html").data());
+    test->waitUntilResourceLoadFinished();
+    g_assert(test->m_resource);
+
+    g_assert_cmpint(events.size(), ==, 4);
+    g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started);
+    g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest);
+    g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Failed);
+    g_assert_cmpint(events[3], ==, SingleResourceLoadTest::Finished);
+    events.clear();
 }
 
 static void addCacheHTTPHeadersToResponse(SoupMessage* message)
@@ -688,6 +727,12 @@
     } else if (g_str_equal(path, "/resource-to-cancel.html")) {
         static const char* resourceToCancelHTML = "<html><head><script language='_javascript_' src=''></script></head><body></body></html>";
         soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, resourceToCancelHTML, strlen(resourceToCancelHTML));
+    } else if (g_str_equal(path, "/redirected-_javascript_.html")) {
+        static const char* _javascript_RelativeHTML = "<html><head><script language='_javascript_' src=''></script></head><body></body></html>";
+        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, _javascript_RelativeHTML, strlen(_javascript_RelativeHTML));
+    } else if (g_str_equal(path, "/redirected-to-cancel.html")) {
+        static const char* _javascript_RelativeHTML = "<html><head><script language='_javascript_' src=''></script></head><body></body></html>";
+        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, _javascript_RelativeHTML, strlen(_javascript_RelativeHTML));
     } else if (g_str_equal(path, "/blank.ico")) {
         GOwnPtr<char> filePath(g_build_filename(Test::getWebKit1TestResoucesDir().data(), path, NULL));
         char* contents;
@@ -707,6 +752,12 @@
     } else if (g_str_equal(path, "/redirected.css")) {
         soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
         soup_message_headers_append(message->response_headers, "Location", "/simple-style.css");
+    } else if (g_str_equal(path, "/redirected.js")) {
+        soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
+        soup_message_headers_append(message->response_headers, "Location", "/remove-this/_javascript_.js");
+    } else if (g_str_equal(path, "/redirected-to-cancel.js")) {
+        soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
+        soup_message_headers_append(message->response_headers, "Location", "/cancel-this.js");
     } else if (g_str_equal(path, "/invalid.css"))
         soup_message_set_status(message, SOUP_STATUS_CANT_CONNECT);
     else
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to