Changeset 235360 in webkit


Ignore:
Timestamp:
Aug 27, 2018 6:40:44 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

XMLHTTPRequest.send for Document should have same Content-Type processing rules as String
https://bugs.webkit.org/show_bug.cgi?id=188953

Patch by Rob Buis <rbuis@igalia.com> on 2018-08-27
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

  • web-platform-tests/xhr/setrequestheader-content-type-expected.txt:

Source/WebCore:

Processing rules for Content-Type have been implemented for send with String as parameter, but
not for Document, but both should be treated the same according to the spec [1]. This patch
implements this.

Behavior matches Firefox.

[1] https://xhr.spec.whatwg.org/#the-send()-method

Test: web-platform-tests/XMLHttpRequest/setrequestheader-content-type.htm

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::send):

LayoutTests:

  • platform/gtk/imported/w3c/web-platform-tests/xhr/setrequestheader-content-type-expected.txt:
  • platform/ios/imported/w3c/web-platform-tests/xhr/setrequestheader-content-type-expected.txt:
  • platform/wpe/imported/w3c/web-platform-tests/xhr/setrequestheader-content-type-expected.txt:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r235354 r235360  
     12018-08-27  Rob Buis  <rbuis@igalia.com>
     2
     3        XMLHTTPRequest.send for Document should have same Content-Type processing rules as String
     4        https://bugs.webkit.org/show_bug.cgi?id=188953
     5
     6        Reviewed by Darin Adler.
     7
     8        * platform/gtk/imported/w3c/web-platform-tests/xhr/setrequestheader-content-type-expected.txt:
     9        * platform/ios/imported/w3c/web-platform-tests/xhr/setrequestheader-content-type-expected.txt:
     10        * platform/wpe/imported/w3c/web-platform-tests/xhr/setrequestheader-content-type-expected.txt:
     11
    1122018-08-27  Youenn Fablet  <youenn@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r235358 r235360  
     12018-08-27  Rob Buis  <rbuis@igalia.com>
     2
     3        XMLHTTPRequest.send for Document should have same Content-Type processing rules as String
     4        https://bugs.webkit.org/show_bug.cgi?id=188953
     5
     6        Reviewed by Darin Adler.
     7
     8        * web-platform-tests/xhr/setrequestheader-content-type-expected.txt:
     9
    1102018-08-27  Ali Juma  <ajuma@chromium.org>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/setrequestheader-content-type-expected.txt

    r235354 r235360  
    1111FAIL XML Document request respects setRequestHeader("") assert_equals: expected "Content-Type: \n" but got "Content-Type:  \n"
    1212PASS XML Document request has correct default Content-Type of "application/xml;charset=UTF-8"
    13 FAIL XML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8 assert_equals: expected "Content-Type: application/xhtml+xml;charset=UTF-8\n" but got "Content-Type: application/xhtml+xml;charset=ASCII\n"
     13PASS XML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8
    1414FAIL HTML Document request respects setRequestHeader("") assert_equals: expected "Content-Type: \n" but got "Content-Type:  \n"
    1515PASS HTML Document request has correct default Content-Type of "text/html;charset=UTF-8"
    16 FAIL HTML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8 assert_equals: expected "Content-Type: text/html+junk;charset=UTF-8\n" but got "Content-Type: text/html+junk;charset=ASCII\n"
     16PASS HTML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8
    1717FAIL Blob request respects setRequestHeader("") to be specified assert_equals: expected "Content-Type: \n" but got "Content-Type:  \n"
    1818FAIL Blob request with unset type sends no Content-Type without setRequestHeader() call assert_equals: expected "" but got "Content-Type:  \n"
  • trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/xhr/setrequestheader-content-type-expected.txt

    r235354 r235360  
    1111FAIL XML Document request respects setRequestHeader("") assert_equals: expected "Content-Type: \n" but got "Content-Type:  \n"
    1212PASS XML Document request has correct default Content-Type of "application/xml;charset=UTF-8"
    13 FAIL XML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8 assert_equals: expected "Content-Type: application/xhtml+xml;charset=UTF-8\n" but got "Content-Type: application/xhtml+xml;charset=ASCII\n"
     13PASS XML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8
    1414FAIL HTML Document request respects setRequestHeader("") assert_equals: expected "Content-Type: \n" but got "Content-Type:  \n"
    1515PASS HTML Document request has correct default Content-Type of "text/html;charset=UTF-8"
    16 FAIL HTML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8 assert_equals: expected "Content-Type: text/html+junk;charset=UTF-8\n" but got "Content-Type: text/html+junk;charset=ASCII\n"
     16PASS HTML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8
    1717FAIL Blob request respects setRequestHeader("") to be specified assert_equals: expected "Content-Type: \n" but got "Content-Type:  \n"
    1818FAIL Blob request with unset type sends no Content-Type without setRequestHeader() call assert_equals: expected "" but got "Content-Type:  \n"
  • trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/xhr/setrequestheader-content-type-expected.txt

    r235354 r235360  
    1111PASS XML Document request respects setRequestHeader("")
    1212PASS XML Document request has correct default Content-Type of "application/xml;charset=UTF-8"
    13 FAIL XML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8 assert_equals: expected "content-type: application/xhtml+xml;charset=utf-8" but got "content-type: application/xhtml+xml;charset=ascii"
     13PASS XML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8
    1414PASS HTML Document request respects setRequestHeader("")
    1515PASS HTML Document request has correct default Content-Type of "text/html;charset=UTF-8"
    16 FAIL HTML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8 assert_equals: expected "content-type: text/html+junk;charset=utf-8" but got "content-type: text/html+junk;charset=ascii"
     16PASS HTML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8
    1717PASS Blob request respects setRequestHeader("") to be specified
    1818FAIL Blob request with unset type sends no Content-Type without setRequestHeader() call assert_equals: expected "" but got "content-type: "
  • trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/xhr/setrequestheader-content-type-expected.txt

    r235354 r235360  
    1111FAIL XML Document request respects setRequestHeader("") assert_equals: expected "Content-Type: \n" but got "Content-Type:  \n"
    1212PASS XML Document request has correct default Content-Type of "application/xml;charset=UTF-8"
    13 FAIL XML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8 assert_equals: expected "Content-Type: application/xhtml+xml;charset=UTF-8\n" but got "Content-Type: application/xhtml+xml;charset=ASCII\n"
     13PASS XML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8
    1414FAIL HTML Document request respects setRequestHeader("") assert_equals: expected "Content-Type: \n" but got "Content-Type:  \n"
    1515PASS HTML Document request has correct default Content-Type of "text/html;charset=UTF-8"
    16 FAIL HTML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8 assert_equals: expected "Content-Type: text/html+junk;charset=UTF-8\n" but got "Content-Type: text/html+junk;charset=ASCII\n"
     16PASS HTML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8
    1717FAIL Blob request respects setRequestHeader("") to be specified assert_equals: expected "Content-Type: \n" but got "Content-Type:  \n"
    1818FAIL Blob request with unset type sends no Content-Type without setRequestHeader() call assert_equals: expected "" but got "Content-Type:  \n"
  • trunk/Source/WebCore/ChangeLog

    r235358 r235360  
     12018-08-27  Rob Buis  <rbuis@igalia.com>
     2
     3        XMLHTTPRequest.send for Document should have same Content-Type processing rules as String
     4        https://bugs.webkit.org/show_bug.cgi?id=188953
     5
     6        Reviewed by Darin Adler.
     7
     8        Processing rules for Content-Type have been implemented for send with String as parameter, but
     9        not for Document, but both should be treated the same according to the spec [1]. This patch
     10        implements this.
     11
     12        Behavior matches Firefox.
     13
     14        [1] https://xhr.spec.whatwg.org/#the-send()-method
     15
     16        Test: web-platform-tests/XMLHttpRequest/setrequestheader-content-type.htm
     17
     18        * xml/XMLHttpRequest.cpp:
     19        (WebCore::XMLHttpRequest::send):
     20
    1212018-08-27  Ali Juma  <ajuma@chromium.org>
    222
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r235355 r235360  
    462462                // FIXME: this should include the charset used for encoding.
    463463                m_requestHeaders.set(HTTPHeaderName::ContentType, document.isHTMLDocument() ? "text/html;charset=UTF-8"_s : "application/xml;charset=UTF-8"_s);
     464        } else {
     465            String contentType = m_requestHeaders.get(HTTPHeaderName::ContentType);
     466            replaceCharsetInMediaType(contentType, "UTF-8");
     467            m_requestHeaders.set(HTTPHeaderName::ContentType, contentType);
    464468        }
    465469
Note: See TracChangeset for help on using the changeset viewer.