Changeset 117246 in webkit


Ignore:
Timestamp:
May 16, 2012 2:46:18 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] xhr request to non existent file response is 0 and not 404.
https://bugs.webkit.org/show_bug.cgi?id=86344

Patch by Jason Liu <jason.liu@torchmobile.com.cn> on 2012-05-16
Reviewed by George Staikos.

Source/WebCore:

NetworkJob receives 404 for a XMLHttpRequest which calls open("HEAD", "notExist.html", true).
There are no data received because its method is HEAD.
This case should not be treated as a failure.

Add shouldNotifyClientFailed() to treat XMLHttpRequest as a special case.
XMLHttpRequest will fail when status code is smaller than zero.

If we use "GET" and receive 404 without body, NetworkJob won't go through failing code path, too.
So add http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html
to check this case.

Test: http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html

http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html

  • platform/network/blackberry/NetworkJob.cpp:

(WebCore::NetworkJob::sendResponseIfNeeded):

LayoutTests:

  • http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html:
Location:
trunk
Files:
2 added
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r117245 r117246  
     12012-05-16  Jason Liu  <jason.liu@torchmobile.com.cn>
     2
     3        [BlackBerry] xhr request to non existent file response is 0 and not 404.
     4        https://bugs.webkit.org/show_bug.cgi?id=86344
     5
     6        Reviewed by George Staikos.
     7
     8        * http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html:
     9
    1102012-05-15  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
    211
  • trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html

    r117245 r117246  
    11<html>
    2 <body>
    3 <p>This tests the readyState of a XMLHttpRequset which is sent with a "HEAD" method to a not exist resource.</p>
    4 <pre id="result">FAIL</pre>
     2<head>
    53<script type="text/javascript">
     4function loadXMLDoc() {
    65
    76    if (window.layoutTestController) {
     
    1514        if (xmlhttp.readyState) {
    1615            res = res + xmlhttp.readyState;
    17             if(res == "124"){
     16            if(res == "124" && xmlhttp.status == 404) {
    1817                document.getElementById('result').innerText = "PASS";
    1918
     
    2423    }
    2524
    26     xmlhttp.open("HEAD","notExist.html",true);
     25    xmlhttp.open("GET", "resources/status-404-without-body.php", true);
    2726    xmlhttp.send();
     27}
    2828</script>
     29</head>
     30<body onload="loadXMLDoc()">
     31<p>This tests the readyState of a XMLHttpRequset which is sended with a "GET" method. And the response's status is 404 without body.</p>
     32<p id="result">FAIL</p>
    2933</body>
    3034</html>
  • trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html

    r114235 r117246  
    1515        if (xmlhttp.readyState) {
    1616            res = res + xmlhttp.readyState;
    17             if(res == "124"){
     17            if(res == "124" && xmlhttp.status == 404) {
    1818                document.getElementById('result').innerText = "PASS";
    1919
  • trunk/Source/WebCore/ChangeLog

    r117242 r117246  
     12012-05-16  Jason Liu  <jason.liu@torchmobile.com.cn>
     2
     3        [BlackBerry] xhr request to non existent file response is 0 and not 404.
     4        https://bugs.webkit.org/show_bug.cgi?id=86344
     5
     6        Reviewed by George Staikos.
     7
     8        NetworkJob receives 404 for a XMLHttpRequest which calls open("HEAD", "notExist.html", true).
     9        There are no data received because its method is HEAD.
     10        This case should not be treated as a failure.
     11
     12        Add shouldNotifyClientFailed() to treat XMLHttpRequest as a special case.
     13        XMLHttpRequest will fail when status code is smaller than zero.
     14
     15        If we use "GET" and receive 404 without body, NetworkJob won't go through failing code path, too.
     16        So add http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html
     17        to check this case.
     18
     19        Test: http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html
     20              http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html
     21        * platform/network/blackberry/NetworkJob.cpp:
     22        (WebCore::NetworkJob::sendResponseIfNeeded):
     23
    1242012-05-16  MORITA Hajime  <morrita@google.com>
    225
  • trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp

    r116591 r117246  
    450450            purgeCredentials();
    451451
    452         if (shouldNotifyClientFinished()) {
     452        if (shouldReleaseClientResource()) {
    453453            if (isRedirect(m_extendedStatusCode) && (m_redirectCount >= s_redirectMaximum))
    454454                m_extendedStatusCode = BlackBerry::Platform::FilterStream::StatusTooManyRedirects;
     
    458458
    459459                RecursionGuard guard(m_callingClient);
    460                 if (isError(m_extendedStatusCode) && !m_dataReceived && m_handle->firstRequest().httpMethod() != "HEAD") {
     460                if (shouldNotifyClientFailed()) {
    461461                    String domain = m_extendedStatusCode < 0 ? ResourceError::platformErrorDomain : ResourceError::httpErrorDomain;
    462462                    ResourceError error(domain, m_extendedStatusCode, m_response.url().string(), m_response.httpStatusText());
     
    477477}
    478478
    479 bool NetworkJob::shouldNotifyClientFinished()
     479bool NetworkJob::shouldReleaseClientResource()
    480480{
    481481    if (m_redirectCount >= s_redirectMaximum)
     
    489489
    490490    return true;
     491}
     492
     493bool NetworkJob::shouldNotifyClientFailed() const
     494{
     495    if (m_handle->firstRequest().targetType() == ResourceRequest::TargetIsXHR)
     496        return m_extendedStatusCode < 0;
     497    return isError(m_extendedStatusCode) && !m_dataReceived;
    491498}
    492499
     
    575582    m_responseSent = true;
    576583
    577     if (isError(m_extendedStatusCode) && !m_dataReceived)
     584    if (shouldNotifyClientFailed())
    578585        return;
    579586
  • trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h

    r116591 r117246  
    9696    bool shouldSendClientData() const;
    9797
    98     bool shouldNotifyClientFinished();
     98    bool shouldReleaseClientResource();
     99    bool shouldNotifyClientFailed() const;
    99100
    100101    bool shouldDeferLoading() const
     
    134135    void purgeCredentials();
    135136
    136     bool isError(int statusCode)
     137    bool isError(int statusCode) const
    137138    {
    138139        return statusCode < 0 || (400 <= statusCode && statusCode < 600);
Note: See TracChangeset for help on using the changeset viewer.