Changeset 220779 in webkit


Ignore:
Timestamp:
Aug 15, 2017 6:23:50 PM (7 years ago)
Author:
Chris Dumez
Message:

Fetch / Beacon: Use "application/octet-stream" Content-Type for payloads of type ArrayBuffer / ArrayBufferView
https://bugs.webkit.org/show_bug.cgi?id=175600

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

  • web-platform-tests/beacon/headers/header-content-type-expected.txt:
  • web-platform-tests/fetch/api/basic/request-headers.any-expected.txt:
  • web-platform-tests/fetch/api/basic/request-headers.any.worker-expected.txt:

Source/WebCore:

Use "application/octet-stream" Content-Type for payloads of type ArrayBuffer / ArrayBufferView in Fetch & Beacon.
If we don't set a Content-Type header, our underlying network stack is going to add a "application/x-www-form-urlencoded"
Content-Type header, which is worse.

Chrome is already using "application/octet-stream" Content-Type in Beacon, but use no Content-Type in Fetch.
The Fetch/Beacon specification says we should have no Content-Type header in this case but this is unfortunately
not something we can support at the moment. Using "application/octet-stream" Content-Type for now seems like the
lesser evil.

Test: http/wpt/fetch/fetch-request-arraybuffer-content-type.html

  • Modules/fetch/FetchBody.cpp:

(WebCore::FetchBody::extract):

  • platform/network/HTTPHeaderValues.cpp:

(WebCore::HTTPHeaderValues::octetStreamContentType):

  • platform/network/HTTPHeaderValues.h:

LayoutTests:

  • http/wpt/fetch/fetch-request-arraybuffer-content-type-expected.txt: Added.
  • http/wpt/fetch/fetch-request-arraybuffer-content-type.html: Added.
  • platform/mac-highsierra/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.any-expected.txt:
  • platform/mac-highsierra/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.any.worker-expected.txt:
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r220776 r220779  
     12017-08-15  Chris Dumez  <cdumez@apple.com>
     2
     3        Fetch / Beacon: Use "application/octet-stream" Content-Type for payloads of type ArrayBuffer / ArrayBufferView
     4        https://bugs.webkit.org/show_bug.cgi?id=175600
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * http/wpt/fetch/fetch-request-arraybuffer-content-type-expected.txt: Added.
     9        * http/wpt/fetch/fetch-request-arraybuffer-content-type.html: Added.
     10        * platform/mac-highsierra/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.any-expected.txt:
     11        * platform/mac-highsierra/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.any.worker-expected.txt:
     12
    1132017-08-15  Matt Lewis  <jlewis3@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r220772 r220779  
     12017-08-15  Chris Dumez  <cdumez@apple.com>
     2
     3        Fetch / Beacon: Use "application/octet-stream" Content-Type for payloads of type ArrayBuffer / ArrayBufferView
     4        https://bugs.webkit.org/show_bug.cgi?id=175600
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * web-platform-tests/beacon/headers/header-content-type-expected.txt:
     9        * web-platform-tests/fetch/api/basic/request-headers.any-expected.txt:
     10        * web-platform-tests/fetch/api/basic/request-headers.any.worker-expected.txt:
     11
    1122017-08-15  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt

    r220494 r220779  
    11
    22PASS Test content-type header for a body string
    3 FAIL Test content-type header for a body ArrayBufferView assert_equals: Correct Content-Type header result expected "" but got "application/x-www-form-urlencoded"
    4 FAIL Test content-type header for a body ArrayBuffer assert_equals: Correct Content-Type header result expected "" but got "application/x-www-form-urlencoded"
     3FAIL Test content-type header for a body ArrayBufferView assert_equals: Correct Content-Type header result expected "" but got "application/octet-stream"
     4FAIL Test content-type header for a body ArrayBuffer assert_equals: Correct Content-Type header result expected "" but got "application/octet-stream"
    55PASS Test content-type header for a body Blob
    66PASS Test content-type header for a body FormData
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.any-expected.txt

    r215515 r220779  
    99PASS Fetch with POST with URLSearchParams body
    1010FAIL Fetch with POST with Blob body assert_equals: Request should have header content-type: null expected (object) null but got (string) ""
    11 FAIL Fetch with POST with ArrayBuffer body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    12 FAIL Fetch with POST with Uint8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    13 FAIL Fetch with POST with Int8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    14 FAIL Fetch with POST with Float32Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    15 FAIL Fetch with POST with Float64Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    16 FAIL Fetch with POST with DataView body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
     11FAIL Fetch with POST with ArrayBuffer body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     12FAIL Fetch with POST with Uint8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     13FAIL Fetch with POST with Int8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     14FAIL Fetch with POST with Float32Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     15FAIL Fetch with POST with Float64Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     16FAIL Fetch with POST with DataView body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
    1717PASS Fetch with POST with Blob body with mime type
    1818FAIL Fetch with Chicken assert_equals: Request should have header content-length: null expected (object) null but got (string) "0"
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.any.worker-expected.txt

    r215515 r220779  
    99PASS Fetch with POST with URLSearchParams body
    1010FAIL Fetch with POST with Blob body assert_equals: Request should have header content-type: null expected (object) null but got (string) ""
    11 FAIL Fetch with POST with ArrayBuffer body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    12 FAIL Fetch with POST with Uint8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    13 FAIL Fetch with POST with Int8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    14 FAIL Fetch with POST with Float32Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    15 FAIL Fetch with POST with Float64Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    16 FAIL Fetch with POST with DataView body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
     11FAIL Fetch with POST with ArrayBuffer body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     12FAIL Fetch with POST with Uint8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     13FAIL Fetch with POST with Int8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     14FAIL Fetch with POST with Float32Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     15FAIL Fetch with POST with Float64Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     16FAIL Fetch with POST with DataView body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
    1717PASS Fetch with POST with Blob body with mime type
    1818FAIL Fetch with Chicken assert_equals: Request should have header content-length: null expected (object) null but got (string) "0"
  • trunk/LayoutTests/platform/mac-highsierra/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.any-expected.txt

    r219523 r220779  
    88PASS Fetch with POST with FormData body
    99PASS Fetch with POST with URLSearchParams body
    10 PASS Fetch with POST with Blob body
    11 FAIL Fetch with POST with ArrayBuffer body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    12 FAIL Fetch with POST with Uint8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    13 FAIL Fetch with POST with Int8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    14 FAIL Fetch with POST with Float32Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    15 FAIL Fetch with POST with Float64Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    16 FAIL Fetch with POST with DataView body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
     10FAIL Fetch with POST with Blob body assert_equals: Request should have header content-type: null expected (object) null but got (string) ""
     11FAIL Fetch with POST with ArrayBuffer body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     12FAIL Fetch with POST with Uint8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     13FAIL Fetch with POST with Int8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     14FAIL Fetch with POST with Float32Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     15FAIL Fetch with POST with Float64Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     16FAIL Fetch with POST with DataView body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
    1717PASS Fetch with POST with Blob body with mime type
    1818FAIL Fetch with Chicken assert_equals: Request should have header content-length: null expected (object) null but got (string) "0"
  • trunk/LayoutTests/platform/mac-highsierra/imported/w3c/web-platform-tests/fetch/api/basic/request-headers.any.worker-expected.txt

    r219523 r220779  
    88FAIL Fetch with POST with FormData body Can't find variable: FormData
    99PASS Fetch with POST with URLSearchParams body
    10 PASS Fetch with POST with Blob body
    11 FAIL Fetch with POST with ArrayBuffer body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    12 FAIL Fetch with POST with Uint8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    13 FAIL Fetch with POST with Int8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    14 FAIL Fetch with POST with Float32Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    15 FAIL Fetch with POST with Float64Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
    16 FAIL Fetch with POST with DataView body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/x-www-form-urlencoded"
     10FAIL Fetch with POST with Blob body assert_equals: Request should have header content-type: null expected (object) null but got (string) ""
     11FAIL Fetch with POST with ArrayBuffer body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     12FAIL Fetch with POST with Uint8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     13FAIL Fetch with POST with Int8Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     14FAIL Fetch with POST with Float32Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     15FAIL Fetch with POST with Float64Array body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
     16FAIL Fetch with POST with DataView body assert_equals: Request should have header content-type: null expected (object) null but got (string) "application/octet-stream"
    1717PASS Fetch with POST with Blob body with mime type
    1818FAIL Fetch with Chicken assert_equals: Request should have header content-length: null expected (object) null but got (string) "0"
  • trunk/Source/WebCore/ChangeLog

    r220778 r220779  
     12017-08-15  Chris Dumez  <cdumez@apple.com>
     2
     3        Fetch / Beacon: Use "application/octet-stream" Content-Type for payloads of type ArrayBuffer / ArrayBufferView
     4        https://bugs.webkit.org/show_bug.cgi?id=175600
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Use "application/octet-stream" Content-Type for payloads of type ArrayBuffer / ArrayBufferView in Fetch & Beacon.
     9        If we don't set a Content-Type header, our underlying network stack is going to add a "application/x-www-form-urlencoded"
     10        Content-Type header, which is worse.
     11
     12        Chrome is already using "application/octet-stream" Content-Type in Beacon, but use no Content-Type in Fetch.
     13        The Fetch/Beacon specification says we should have no Content-Type header in this case but this is unfortunately
     14        not something we can support at the moment. Using "application/octet-stream" Content-Type for now seems like the
     15        lesser evil.
     16
     17        Test: http/wpt/fetch/fetch-request-arraybuffer-content-type.html
     18
     19        * Modules/fetch/FetchBody.cpp:
     20        (WebCore::FetchBody::extract):
     21        * platform/network/HTTPHeaderValues.cpp:
     22        (WebCore::HTTPHeaderValues::octetStreamContentType):
     23        * platform/network/HTTPHeaderValues.h:
     24
    1252017-08-15  Robin Morisset  <rmorisset@apple.com>
    226
  • trunk/Source/WebCore/Modules/fetch/FetchBody.cpp

    r220279 r220779  
    6363    if (WTF::holds_alternative<RefPtr<ArrayBuffer>>(value)) {
    6464        Ref<const ArrayBuffer> buffer = WTF::get<RefPtr<ArrayBuffer>>(value).releaseNonNull();
     65        // FIXME: We should not set a Content-Type here but we need to do this until all network stacks
     66        // support sending no Content-Type header (<dar://problem/33906567).
     67        contentType = HTTPHeaderValues::octetStreamContentType();
    6568        return FetchBody(WTFMove(buffer));
    6669    }
    6770    if (WTF::holds_alternative<RefPtr<ArrayBufferView>>(value)) {
    6871        Ref<const ArrayBufferView> buffer = WTF::get<RefPtr<ArrayBufferView>>(value).releaseNonNull();
     72        // FIXME: We should not set a Content-Type here but we need to do this until all network stacks
     73        // support sending no Content-Type header (<dar://problem/33906567).
     74        contentType = HTTPHeaderValues::octetStreamContentType();
    6975        return FetchBody(WTFMove(buffer));
    7076    }
  • trunk/Source/WebCore/platform/network/HTTPHeaderValues.cpp

    r216217 r220779  
    4545}
    4646
     47const String& octetStreamContentType()
     48{
     49    static NeverDestroyed<const String> contentType(MAKE_STATIC_STRING_IMPL("application/octet-stream"));
     50    return contentType;
     51}
     52
    4753const String& noCache()
    4854{
  • trunk/Source/WebCore/platform/network/HTTPHeaderValues.h

    r207086 r220779  
    3333const String& textPlainContentType();
    3434const String& formURLEncodedContentType();
     35const String& octetStreamContentType();
    3536const String& noCache();
    3637const String& maxAge0();
Note: See TracChangeset for help on using the changeset viewer.