Changeset 201557 in webkit


Ignore:
Timestamp:
Jun 1, 2016 10:14:09 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

POST request on a blob resource should return a "network error" instead of HTTP 500 response
https://bugs.webkit.org/show_bug.cgi?id=158022

Patch by Nael Ouedraogo <nael.ouedraogo@crf.canon.fr> on 2016-06-01
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Make sure request on blob resource is correct.

  • web-platform-tests/fetch/api/basic/scheme-blob-expected.txt:
  • web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt:
  • web-platform-tests/fetch/api/basic/scheme-blob.js: Add new tests with several HTTP methods.

Source/WebCore:

Not allowed HTTP method is notified as failed in BlobResourceHandle as per Fetch
specification (5.2 Basic fetch). This behavior is observable in fetch WPT tests.

The behavior of XHR is slightly changed for asynchronous request on a blob resource with not
allowed or invalid HTTP methods. The onError callback is called instead of throwing an
exception as per XHR specification (https://xhr.spec.whatwg.org/#request-error-steps).

WPT tests expected results have been updated for fetch tests on blob resources which are
now correct.

Test: fast/files/xhr-blob-request.html ensures XHR response to requests on a blob resource is
correct.

  • platform/network/BlobResourceHandle.cpp:

(WebCore::BlobResourceHandle::doStart):

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::createRequest):

LayoutTests:

Make sure response to XHR request on blob is correct.

  • fast/files/xhr-blob-request-expected.txt: Added.
  • fast/files/xhr-blob-request.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r201554 r201557  
     12016-06-01  Nael Ouedraogo  <nael.ouedraogo@crf.canon.fr>
     2
     3        POST request on a blob resource should return a "network error" instead of HTTP 500 response
     4        https://bugs.webkit.org/show_bug.cgi?id=158022
     5
     6        Reviewed by Alex Christensen.
     7
     8        Make sure response to XHR request on blob is correct.
     9
     10        * fast/files/xhr-blob-request-expected.txt: Added.
     11        * fast/files/xhr-blob-request.html: Added.
     12
    1132016-06-01  Javier Fernandez  <jfernandez@igalia.com>
    214
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r201555 r201557  
     12016-06-01  Nael Ouedraogo  <nael.ouedraogo@crf.canon.fr>
     2
     3        POST request on a blob resource should return a "network error" instead of HTTP 500 response
     4        https://bugs.webkit.org/show_bug.cgi?id=158022
     5
     6        Reviewed by Alex Christensen.
     7
     8        Make sure request on blob resource is correct.
     9
     10        * web-platform-tests/fetch/api/basic/scheme-blob-expected.txt:
     11        * web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt:
     12        * web-platform-tests/fetch/api/basic/scheme-blob.js: Add new tests with several HTTP methods.
     13
    1142016-06-01  Youenn Fablet  <youenn.fablet@crf.canon.fr>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt

    r198888 r201557  
    22PASS Fetching [GET] URL.createObjectURL(blob) is OK
    33PASS Fetching [GET] blob:http://www.localhost:8800/ is KO
    4 FAIL Fetching [POST] URL.createObjectURL(blob) is KO assert_unreached: Should have rejected. Reached unreachable code
     4PASS Fetching [POST] URL.createObjectURL(blob) is KO
     5PASS Fetching [OPTIONS] URL.createObjectURL(blob) is KO
     6PASS Fetching [HEAD] URL.createObjectURL(blob) is KO
     7PASS Fetching [PUT] URL.createObjectURL(blob) is KO
     8PASS Fetching [DELETE] URL.createObjectURL(blob) is KO
     9PASS Fetching [INVALID] URL.createObjectURL(blob) is KO
    510
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt

    r198891 r201557  
    22PASS Fetching [GET] URL.createObjectURL(blob) is OK
    33PASS Fetching [GET] blob:http://www.localhost:8800/ is KO
    4 FAIL Fetching [POST] URL.createObjectURL(blob) is KO assert_unreached: Should have rejected. Reached unreachable code
     4PASS Fetching [POST] URL.createObjectURL(blob) is KO
     5PASS Fetching [OPTIONS] URL.createObjectURL(blob) is KO
     6PASS Fetching [HEAD] URL.createObjectURL(blob) is KO
     7PASS Fetching [PUT] URL.createObjectURL(blob) is KO
     8PASS Fetching [DELETE] URL.createObjectURL(blob) is KO
     9PASS Fetching [INVALID] URL.createObjectURL(blob) is KO
    510
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.js

    r198888 r201557  
    3333checkKoUrl("blob:http://{{domains[www]}}:{{ports[http][0]}}/", "GET",
    3434          "Fetching [GET] blob:http://{{domains[www]}}:{{ports[http][0]}}/ is KO");
    35 checkKoUrl(URL.createObjectURL(blob2), "POST",
    36            "Fetching [POST] URL.createObjectURL(blob) is KO");
     35
     36var invalidRequestMethods = [
     37  "POST",
     38  "OPTIONS",
     39  "HEAD",
     40  "PUT",
     41  "DELETE",
     42  "INVALID",
     43];
     44invalidRequestMethods.forEach(function(method) {
     45  checkKoUrl(URL.createObjectURL(blob2), method, "Fetching [" + method + "] URL.createObjectURL(blob) is KO");
     46});
    3747
    3848done();
  • trunk/Source/WebCore/ChangeLog

    r201556 r201557  
     12016-06-01  Nael Ouedraogo  <nael.ouedraogo@crf.canon.fr>
     2
     3        POST request on a blob resource should return a "network error" instead of HTTP 500 response
     4        https://bugs.webkit.org/show_bug.cgi?id=158022
     5
     6        Reviewed by Alex Christensen.
     7
     8        Not allowed HTTP method is notified as failed in BlobResourceHandle as per Fetch
     9        specification (5.2 Basic fetch). This behavior is observable in fetch WPT tests.
     10
     11        The behavior of XHR is slightly changed for asynchronous request on a blob resource with not
     12        allowed or invalid HTTP methods. The onError callback is called instead of throwing an
     13        exception as per XHR specification (https://xhr.spec.whatwg.org/#request-error-steps).
     14
     15        WPT tests expected results have been updated for fetch tests on blob resources which are
     16        now correct.
     17
     18        Test: fast/files/xhr-blob-request.html ensures XHR response to requests on a blob resource is
     19        correct.
     20
     21        * platform/network/BlobResourceHandle.cpp:
     22        (WebCore::BlobResourceHandle::doStart):
     23        * xml/XMLHttpRequest.cpp:
     24        (WebCore::XMLHttpRequest::createRequest):
     25
    1262016-06-01  Youenn Fablet  <youenn.fablet@crf.canon.fr>
    227
  • trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp

    r201482 r201557  
    203203
    204204    if (!equalLettersIgnoringASCIICase(firstRequest().httpMethod(), "get")) {
    205         m_errorCode = methodNotAllowed;
    206         notifyResponse();
     205        notifyFail(methodNotAllowed);
    207206        return;
    208207    }
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r200895 r201557  
    669669{
    670670    // Only GET request is supported for blob URL.
    671     if (m_url.protocolIsBlob() && m_method != "GET") {
     671    if (!m_async && m_url.protocolIsBlob() && m_method != "GET") {
    672672        ec = NETWORK_ERR;
    673673        return;
Note: See TracChangeset for help on using the changeset viewer.