Changeset 262776 in webkit


Ignore:
Timestamp:
Jun 8, 2020 11:44:48 PM (4 years ago)
Author:
commit-queue@webkit.org
Message:

XMLHTTPRequest.send should not send Content-Type headers when Blob has no type
https://bugs.webkit.org/show_bug.cgi?id=211999

Patch by Rob Buis <rbuis@igalia.com> on 2020-06-08
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Update improved test expectation.

  • web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt:

Source/WebCore:

XMLHTTPRequest.send should not send Content-Type headers when Blob has no type [1, 2].
This behavior overrides the behavior of the File API spec [3].

Behavior matches Firefox and Chrome.

Test: imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type.html

[1] https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send
[2] https://fetch.spec.whatwg.org/#concept-bodyinit-extract
[3] http://dev.w3.org/2006/webapi/FileAPI/#dfn-type

  • platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:

(-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]):

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::send):

LayoutTests:

Remove unneeded expectations.

  • platform/ios/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt: Removed.
  • platform/mac/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt: Removed.
Location:
trunk
Files:
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r262774 r262776  
     12020-06-08  Rob Buis  <rbuis@igalia.com>
     2
     3        XMLHTTPRequest.send should not send Content-Type headers when Blob has no type
     4        https://bugs.webkit.org/show_bug.cgi?id=211999
     5
     6        Reviewed by Alex Christensen.
     7
     8        Remove unneeded expectations.
     9
     10        * platform/ios/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt: Removed.
     11        * platform/mac/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt: Removed.
     12
    1132020-06-08  Simon Fraser  <simon.fraser@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r262720 r262776  
     12020-06-08  Rob Buis  <rbuis@igalia.com>
     2
     3        XMLHTTPRequest.send should not send Content-Type headers when Blob has no type
     4        https://bugs.webkit.org/show_bug.cgi?id=211999
     5
     6        Reviewed by Alex Christensen.
     7
     8        Update improved test expectation.
     9
     10        * web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt:
     11
    1122020-06-05  Sergio Villar Senin  <svillar@igalia.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type-expected.txt

    r235354 r262776  
    11
    2 FAIL Synchronous blob loading with no mime type [POST] assert_equals: expected "NO" but got ""
    3 FAIL Asynchronous blob loading with no mime type [POST] assert_equals: expected "NO" but got ""
    4 FAIL Synchronous blob loading with no mime type [PUT] assert_equals: expected "NO" but got ""
    5 FAIL Asynchronous blob loading with no mime type [PUT] assert_equals: expected "NO" but got ""
    6 FAIL Synchronous blob loading with invalid mime type [POST] assert_equals: expected "NO" but got ""
    7 FAIL Asynchronous blob loading with invalid mime type [POST] assert_equals: expected "NO" but got ""
    8 FAIL Synchronous blob loading with invalid mime type [PUT] assert_equals: expected "NO" but got ""
    9 FAIL Asynchronous blob loading with invalid mime type [PUT] assert_equals: expected "NO" but got ""
     2PASS Synchronous blob loading with no mime type [POST]
     3PASS Asynchronous blob loading with no mime type [POST]
     4PASS Synchronous blob loading with no mime type [PUT]
     5PASS Asynchronous blob loading with no mime type [PUT]
     6PASS Synchronous blob loading with invalid mime type [POST]
     7PASS Asynchronous blob loading with invalid mime type [POST]
     8PASS Synchronous blob loading with invalid mime type [PUT]
     9PASS Asynchronous blob loading with invalid mime type [PUT]
    1010
  • trunk/Source/WebCore/ChangeLog

    r262774 r262776  
     12020-06-08  Rob Buis  <rbuis@igalia.com>
     2
     3        XMLHTTPRequest.send should not send Content-Type headers when Blob has no type
     4        https://bugs.webkit.org/show_bug.cgi?id=211999
     5
     6        Reviewed by Alex Christensen.
     7
     8        XMLHTTPRequest.send should not send Content-Type headers when Blob has no type [1, 2].
     9        This behavior overrides the behavior of the File API spec [3].
     10
     11        Behavior matches Firefox and Chrome.
     12
     13        Test: imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type.html
     14
     15        [1] https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send
     16        [2] https://fetch.spec.whatwg.org/#concept-bodyinit-extract
     17        [3] http://dev.w3.org/2006/webapi/FileAPI/#dfn-type
     18
     19        * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
     20        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]):
     21        * xml/XMLHttpRequest.cpp:
     22        (WebCore::XMLHttpRequest::send):
     23
    1242020-06-08  Simon Fraser  <simon.fraser@apple.com>
    225
  • trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm

    r256632 r262776  
    122122
    123123    // See <rdar://problem/5380697>. This is a workaround for a behavior change in CFNetwork where willSendRequest gets called more often.
    124     if (!redirectResponse)
     124    if (!redirectResponse) {
     125        // CFNetwork will add "application/x-www-form-urlencoded" content-type for POST, even if no Content-Type was specified, remove it in that case.
     126        if (equalLettersIgnoringASCIICase(m_handle->firstRequest().httpMethod(), "post") && !m_handle->firstRequest().hasHTTPHeaderField(HTTPHeaderName::ContentType)) {
     127            NSMutableURLRequest *modifiedRequest = [newRequest mutableCopy];
     128            [modifiedRequest setValue:nil forHTTPHeaderField:@"Content-Type"];
     129            return modifiedRequest;
     130        }
    125131        return newRequest;
     132    }
    126133
    127134#if !LOG_DISABLED
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r262369 r262776  
    531531            if (!blobType.isEmpty() && isValidContentType(blobType))
    532532                m_requestHeaders.set(HTTPHeaderName::ContentType, blobType);
    533             else {
    534                 // From FileAPI spec, whenever media type cannot be determined, empty string must be returned.
    535                 m_requestHeaders.set(HTTPHeaderName::ContentType, emptyString());
    536             }
    537533        }
    538534
Note: See TracChangeset for help on using the changeset viewer.