Changeset 161176 in webkit


Ignore:
Timestamp:
Dec 31, 2013 12:28:17 AM (10 years ago)
Author:
Carlos Garcia Campos
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):

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r161167 r161176  
     12013-12-30  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [SOUP] willSendRequest doesn't work after a redirect
     4        https://bugs.webkit.org/show_bug.cgi?id=126290
     5
     6        Reviewed by Martin Robinson.
     7
     8        The problem is that we are creating the new soup request for the
     9        redirect before calling ResourceHandleClient::willSendRequest() so
     10        that any change made to the request by the client is ignored.
     11
     12        * platform/network/soup/ResourceHandleSoup.cpp:
     13        (WebCore::doRedirect): Create the new soup request and soup
     14        message for the redirect after calling willSendRequest() on the
     15        client.
     16
    1172013-12-30  Andreas Kling  <akling@apple.com>
    218
  • trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp

    r161109 r161176  
    503503        applyAuthenticationToRequest(handle, newRequest, true);
    504504
    505     cleanupSoupRequestOperation(handle);
    506     if (!createSoupRequestAndMessageForHandle(handle, newRequest, true)) {
    507         d->client()->cannotShowURL(handle);
    508         return;
    509     }
    510 
    511505    // If we sent credentials with this request's URL, we don't want the response to carry them to
    512506    // the WebKit layer. They were only placed in the URL for the benefit of libsoup.
     
    517511    else
    518512        d->client()->willSendRequest(handle, newRequest, d->m_response);
     513
     514    cleanupSoupRequestOperation(handle);
     515
     516    // willSendRequest might cancel the load.
     517    if (handle->cancelledOrClientless())
     518        return;
     519
     520    if (!createSoupRequestAndMessageForHandle(handle, newRequest, true)) {
     521        d->client()->cannotShowURL(handle);
     522        return;
     523    }
     524
    519525    handle->sendPendingRequest();
    520526}
  • trunk/Source/WebKit2/ChangeLog

    r161173 r161176  
     12013-12-30  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [SOUP] willSendRequest doesn't work after a redirect
     4        https://bugs.webkit.org/show_bug.cgi?id=126290
     5
     6        Reviewed by Martin Robinson.
     7
     8        Add test cases to test send-request signal in case of
     9        redirection.
     10
     11        * UIProcess/API/gtk/tests/TestResources.cpp:
     12        (testWebResourceSendRequest):
     13        (serverCallback):
     14
    1152013-12-30  Commit Queue  <commit-queue@webkit.org>
    216
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp

    r160965 r161176  
    569569            return;
    570570
    571         g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, m_expectedNewResourceURI.data());
     571        if (redirectResponse)
     572            g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, m_expectedNewResourceURIAfterRedirection.data());
     573        else
     574            g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, m_expectedNewResourceURI.data());
    572575        g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, webkit_web_resource_get_uri(resource));
    573576
     
    596599    }
    597600
     601    void setExpectedNewResourceURIAfterRedirection(const CString& uri)
     602    {
     603        m_expectedNewResourceURIAfterRedirection = uri;
     604    }
     605
    598606    CString m_expectedNewResourceURI;
    599607    CString m_expectedCancelledResourceURI;
     608    CString m_expectedNewResourceURIAfterRedirection;
    600609};
    601610
     
    626635    g_assert_cmpint(events[1], ==, SingleResourceLoadTest::Failed);
    627636    g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Finished);
     637    events.clear();
     638
     639    // URI changed after a redirect.
     640    test->setExpectedNewResourceURI(kServer->getURIForPath("/redirected.js"));
     641    test->setExpectedNewResourceURIAfterRedirection(kServer->getURIForPath("/javascript.js"));
     642    test->loadURI(kServer->getURIForPath("redirected-javascript.html").data());
     643    test->waitUntilResourceLoadFinished();
     644    g_assert(test->m_resource);
     645
     646    g_assert_cmpint(events.size(), ==, 6);
     647    g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started);
     648    g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest);
     649    g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Redirected);
     650    g_assert_cmpint(events[3], ==, SingleResourceLoadTest::ReceivedResponse);
     651    g_assert_cmpint(events[4], ==, SingleResourceLoadTest::ReceivedData);
     652    g_assert_cmpint(events[5], ==, SingleResourceLoadTest::Finished);
     653    events.clear();
     654
     655    // Cancel after a redirect.
     656    test->setExpectedNewResourceURI(kServer->getURIForPath("/redirected-to-cancel.js"));
     657    test->setExpectedCancelledResourceURI(kServer->getURIForPath("/redirected-to-cancel.js"));
     658    test->loadURI(kServer->getURIForPath("/redirected-to-cancel.html").data());
     659    test->waitUntilResourceLoadFinished();
     660    g_assert(test->m_resource);
     661
     662    g_assert_cmpint(events.size(), ==, 4);
     663    g_assert_cmpint(events[0], ==, SingleResourceLoadTest::Started);
     664    g_assert_cmpint(events[1], ==, SingleResourceLoadTest::SentRequest);
     665    g_assert_cmpint(events[2], ==, SingleResourceLoadTest::Failed);
     666    g_assert_cmpint(events[3], ==, SingleResourceLoadTest::Finished);
    628667    events.clear();
    629668}
     
    689728        static const char* resourceToCancelHTML = "<html><head><script language='javascript' src='cancel-this.js'></script></head><body></body></html>";
    690729        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, resourceToCancelHTML, strlen(resourceToCancelHTML));
     730    } else if (g_str_equal(path, "/redirected-javascript.html")) {
     731        static const char* javascriptRelativeHTML = "<html><head><script language='javascript' src='/redirected.js'></script></head><body></body></html>";
     732        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, javascriptRelativeHTML, strlen(javascriptRelativeHTML));
     733    } else if (g_str_equal(path, "/redirected-to-cancel.html")) {
     734        static const char* javascriptRelativeHTML = "<html><head><script language='javascript' src='/redirected-to-cancel.js'></script></head><body></body></html>";
     735        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, javascriptRelativeHTML, strlen(javascriptRelativeHTML));
    691736    } else if (g_str_equal(path, "/blank.ico")) {
    692737        GOwnPtr<char> filePath(g_build_filename(Test::getWebKit1TestResoucesDir().data(), path, NULL));
     
    708753        soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
    709754        soup_message_headers_append(message->response_headers, "Location", "/simple-style.css");
     755    } else if (g_str_equal(path, "/redirected.js")) {
     756        soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
     757        soup_message_headers_append(message->response_headers, "Location", "/remove-this/javascript.js");
     758    } else if (g_str_equal(path, "/redirected-to-cancel.js")) {
     759        soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
     760        soup_message_headers_append(message->response_headers, "Location", "/cancel-this.js");
    710761    } else if (g_str_equal(path, "/invalid.css"))
    711762        soup_message_set_status(message, SOUP_STATUS_CANT_CONNECT);
Note: See TracChangeset for help on using the changeset viewer.