Changeset 206014 in webkit


Ignore:
Timestamp:
Sep 16, 2016 1:24:18 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

[Fetch API] Headers should be combine with ',' and not ', '
https://bugs.webkit.org/show_bug.cgi?id=161736

Patch by Youenn Fablet <youenn@apple.com> on 2016-09-16
Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

  • web-platform-tests/XMLHttpRequest/setrequestheader-case-insensitive.htm: Making ',' combination as expected.
  • web-platform-tests/XMLHttpRequest/setrequestheader-header-allowed-expected.txt: Some new header tests are failing.

This is due to the fact that the underlying HTTP code is probably reprocessing those headers and readding ', ' in lieu of ','.

  • web-platform-tests/XMLHttpRequest/setrequestheader-header-allowed.htm: Ditto.
  • web-platform-tests/fetch/api/cors/cors-preflight.js:

(corsPreflight): Removing stripping of whitespaces

  • web-platform-tests/fetch/api/headers/headers-combine.html: Making ',' combination as expected.

Source/WebCore:

Covered by updated tests and http/tests/xmlhttprequest/check-combining-headers.html.

  • loader/CrossOriginAccessControl.cpp:

(WebCore::createAccessControlPreflightRequest): Combining with ',' for Access-Control-Request-Headers

  • platform/network/HTTPHeaderMap.cpp:

(HTTPHeaderMap::add): Combining with ','

LayoutTests:

  • http/tests/xmlhttprequest/check-combining-headers-expected.txt:
  • http/tests/xmlhttprequest/check-combining-headers.html: Checking combined headers.
  • http/tests/xmlhttprequest/resources/print-headers.php: Printing all request headers in a JSON response.
  • http/tests/xmlhttprequest/web-apps/005.html: Making ',' combination as expected.
Location:
trunk
Files:
2 added
11 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r206011 r206014  
     12016-09-16  Youenn Fablet  <youenn@apple.com>
     2
     3        [Fetch API] Headers should be combine with ',' and not ', '
     4        https://bugs.webkit.org/show_bug.cgi?id=161736
     5
     6        Reviewed by Sam Weinig.
     7
     8        * http/tests/xmlhttprequest/check-combining-headers-expected.txt:
     9        * http/tests/xmlhttprequest/check-combining-headers.html: Checking combined headers.
     10        * http/tests/xmlhttprequest/resources/print-headers.php: Printing all request headers in a JSON response.
     11        * http/tests/xmlhttprequest/web-apps/005.html: Making ',' combination as expected.
     12
    1132016-09-16  Youenn Fablet  <youenn@apple.com>
    214
  • trunk/LayoutTests/http/tests/xmlhttprequest/check-combining-headers.html

    r206011 r206014  
    22<html>
    33  <head>
    4     <title>XMLHttpRequest: setRequestHeader() - headers that are allowed</title>
     4    <title>XMLHttpRequest: setRequestHeader() - combining headers </title>
    55    <script src="/resources/testharness.js"></script>
    66    <script src="/resources/testharnessreport.js"></script>
    7     <link rel="help" href="https://xhr.spec.whatwg.org/#the-setrequestheader()-method" data-tested-assertations="/following::ol/li[6] /following::ol/li[7]" /> 
     7    <link rel="help" href="https://xhr.spec.whatwg.org/#the-setrequestheader()-method" data-tested-assertations="/following::ol/li[6] /following::ol/li[7]" />
    88  </head>
    99  <body>
    1010    <div id="log"></div>
    1111    <script>
    12       function request(header) {
     12      function request(header, doNotshowFullValueInError) {
    1313        test(function() {
    1414          var client = new XMLHttpRequest()
    15           client.open("POST", "resources/inspect-headers.py?filter_value=t1, t2", false)
     15          client.open("POST", "resources/print-headers.php", false)
    1616          client.setRequestHeader(header, "t1")
    1717          client.setRequestHeader(header, "t2")
    1818          client.send(null)
    19           assert_equals(client.responseText, header.toLowerCase() + ",")
     19          if (!doNotshowFullValueInError)
     20              assert_equals(JSON.parse(client.response)[header.toLowerCase()], "t1,t2", "Combined header value should be t1,t2")
     21          else
     22              assert_true(JSON.parse(client.response)[header.toLowerCase()] == "t1,t2", "Combined header value should be t1,t2")
    2023        }, document.title + " (" + header + ")")
    2124      }
    2225      request("Authorization")
    2326      request("Pragma")
    24       request("User-Agent")
     27      request("User-Agent", true)
    2528      request("Content-Transfer-Encoding")
    2629      request("Content-Type")
  • trunk/LayoutTests/http/tests/xmlhttprequest/web-apps/005.html

    r120167 r206014  
    2020   r.setRequestHeader('X-Test-Header', 'TWO');
    2121   r.send(null);
    22    if (r.responseText == 'RESULT:[ONE, TWO]') {
     22   if (r.responseText == 'RESULT:[ONE,TWO]') {
    2323     p.firstChild.data = 'PASS';
    2424   } else {
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r206009 r206014  
     12016-09-16  Youenn Fablet  <youenn@apple.com>
     2
     3        [Fetch API] Headers should be combine with ',' and not ', '
     4        https://bugs.webkit.org/show_bug.cgi?id=161736
     5
     6        Reviewed by Sam Weinig.
     7
     8        * web-platform-tests/XMLHttpRequest/setrequestheader-case-insensitive.htm: Making ',' combination as expected.
     9        * web-platform-tests/XMLHttpRequest/setrequestheader-header-allowed-expected.txt: Some new header tests are failing.
     10        This is due to the fact that the underlying HTTP code is probably reprocessing those headers and readding ', ' in lieu of ','.
     11        * web-platform-tests/XMLHttpRequest/setrequestheader-header-allowed.htm: Ditto.
     12        * web-platform-tests/fetch/api/cors/cors-preflight.js:
     13        (corsPreflight): Removing stripping of whitespaces
     14        * web-platform-tests/fetch/api/headers/headers-combine.html: Making ',' combination as expected.
     15
    1162016-09-16  Youenn Fablet  <youenn@apple.com>
    217
  • trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-case-insensitive.htm

    r191546 r206014  
    1212      test(function() {
    1313        var client = new XMLHttpRequest()
    14         client.open("POST", "resources/inspect-headers.py?filter_value=t1, t2, t3", false)
     14        client.open("POST", "resources/inspect-headers.py?filter_value=t1,t2,t3", false)
    1515        client.setRequestHeader("x-test", "t1")
    1616        client.setRequestHeader("X-TEST", "t2")
  • trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-header-allowed-expected.txt

    r191546 r206014  
    44CONSOLE MESSAGE: line 17: Refused to set unsafe header "Content-Transfer-Encoding"
    55
    6 PASS XMLHttpRequest: setRequestHeader() - headers that are allowed (Authorization)
    7 PASS XMLHttpRequest: setRequestHeader() - headers that are allowed (Pragma)
     6FAIL XMLHttpRequest: setRequestHeader() - headers that are allowed (Authorization) assert_equals: expected "authorization," but got ""
     7FAIL XMLHttpRequest: setRequestHeader() - headers that are allowed (Pragma) assert_equals: expected "pragma," but got ""
    88FAIL XMLHttpRequest: setRequestHeader() - headers that are allowed (User-Agent) assert_equals: expected "user-agent," but got ""
    99FAIL XMLHttpRequest: setRequestHeader() - headers that are allowed (Content-Transfer-Encoding) assert_equals: expected "content-transfer-encoding," but got ""
    10 PASS XMLHttpRequest: setRequestHeader() - headers that are allowed (Content-Type)
     10FAIL XMLHttpRequest: setRequestHeader() - headers that are allowed (Content-Type) assert_equals: expected "content-type," but got ""
    1111PASS XMLHttpRequest: setRequestHeader() - headers that are allowed (Overwrite)
    1212PASS XMLHttpRequest: setRequestHeader() - headers that are allowed (If)
  • trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-header-allowed.htm

    r191546 r206014  
    1313        test(function() {
    1414          var client = new XMLHttpRequest()
    15           client.open("POST", "resources/inspect-headers.py?filter_value=t1, t2", false)
     15          client.open("POST", "resources/inspect-headers.py?filter_value=t1,t2", false)
    1616          client.setRequestHeader(header, "t1")
    1717          client.setRequestHeader(header, "t2")
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-preflight.js

    r205743 r206014  
    5353
    5454            let accessControlAllowHeaders = headerNames(headers).sort().join(",");
    55             assert_equals(resp.headers.get("x-control-request-headers").replace(new RegExp(" ", "g"), ""), accessControlAllowHeaders, "Access-Control-Allow-Headers value");
     55            assert_equals(resp.headers.get("x-control-request-headers"), accessControlAllowHeaders, "Access-Control-Allow-Headers value");
    5656            return fetch(RESOURCES_DIR + "clean-stash.py?token=" + uuid_token);
    5757          }
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-combine-expected.txt

    r205743 r206014  
    11
    2 FAIL Create headers using same name for different values assert_equals: name: double has value: doubleValue1,doubleValue2 expected "doubleValue1,doubleValue2" but got "doubleValue1, doubleValue2"
     2PASS Create headers using same name for different values
    33PASS Check delete and has methods when using same name for different values
    44PASS Check set methods when called with already used name
    5 FAIL Check append methods when called with already used name assert_equals: name: single has value: singleValue, newSingleValue expected "singleValue,newSingleValue" but got "singleValue, newSingleValue"
     5PASS Check append methods when called with already used name
    66
  • trunk/Source/WebCore/ChangeLog

    r206011 r206014  
     12016-09-16  Youenn Fablet  <youenn@apple.com>
     2
     3        [Fetch API] Headers should be combine with ',' and not ', '
     4        https://bugs.webkit.org/show_bug.cgi?id=161736
     5
     6        Reviewed by Sam Weinig.
     7
     8        Covered by updated tests and http/tests/xmlhttprequest/check-combining-headers.html.
     9
     10        * loader/CrossOriginAccessControl.cpp:
     11        (WebCore::createAccessControlPreflightRequest): Combining with ',' for Access-Control-Request-Headers
     12        * platform/network/HTTPHeaderMap.cpp:
     13        (HTTPHeaderMap::add): Combining with ','
     14
    1152016-09-16  Youenn Fablet  <youenn@apple.com>
    216
  • trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp

    r206009 r206014  
    129129        bool appendComma = false;
    130130        for (const auto& headerField : unsafeHeaders) {
    131             // FIXME: header names should be separated by 0x2C, without space.
    132131            if (appendComma)
    133                 headerBuffer.appendLiteral(", ");
     132                headerBuffer.append(',');
    134133            else
    135134                appendComma = true;
  • trunk/Source/WebCore/platform/network/HTTPHeaderMap.cpp

    r202126 r206014  
    9898        auto result = m_uncommonHeaders.add(name, value);
    9999        if (!result.isNewEntry)
    100             result.iterator->value = result.iterator->value + ", " + value;
     100            result.iterator->value = makeString(result.iterator->value, ",", value);
    101101        return;
    102102    }
Note: See TracChangeset for help on using the changeset viewer.