Title: [261821] trunk
Revision
261821
Author
commit-qu...@webkit.org
Date
2020-05-18 10:52:59 -0700 (Mon, 18 May 2020)

Log Message

Remove certain headers when a redirect causes a request method change
https://bugs.webkit.org/show_bug.cgi?id=205119

Patch by Rob Buis <rb...@igalia.com> on 2020-05-18
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Sync fetch/api/redirect (ba2e4f92).

* resources/import-expectations.json:
* web-platform-tests/fetch/api/redirect/redirect-count.any.js:
(redirectCount):
* web-platform-tests/fetch/api/redirect/redirect-empty-location.any.js:
* web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any-expected.txt: Added.
* web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.html: Added.
* web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.js: Added.
(redirectLocation):
* web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.worker-expected.txt: Added.
* web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.worker.html: Added.
* web-platform-tests/fetch/api/redirect/redirect-location.any.js:
(redirectLocation):
* web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt:
* web-platform-tests/fetch/api/redirect/redirect-method.any.js:
(redirectMethod):
* web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt:
* web-platform-tests/fetch/api/redirect/redirect-mode.any.js:
(testRedirect):
* web-platform-tests/fetch/api/redirect/redirect-origin.any-expected.txt:
* web-platform-tests/fetch/api/redirect/redirect-origin.any.js:
(testOriginAfterRedirection):
* web-platform-tests/fetch/api/redirect/redirect-origin.any.worker-expected.txt:
* web-platform-tests/fetch/api/redirect/redirect-referrer.any.js:
* web-platform-tests/fetch/api/redirect/redirect-schemes.html:
* web-platform-tests/fetch/api/redirect/redirect-to-dataurl.any.js:
(redirectDataURL):
* web-platform-tests/fetch/api/redirect/w3c-import.log:
* web-platform-tests/fetch/api/resources/keepalive-iframe.html:
* web-platform-tests/fetch/api/resources/method.py:
(main):
* web-platform-tests/fetch/api/resources/preflight.py:
(main):
* web-platform-tests/fetch/api/resources/redirect.py:
(main):
* web-platform-tests/fetch/api/resources/stash-put.py:
(main):
* web-platform-tests/fetch/api/resources/trickle.py:

Source/WebCore:

Implement step 11 of HTTP-redirect fetch [1] to redirect to GET
method, remove body and strip certain headers for 301, 302 and 303 redirects.

Tests: imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.html
       imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker.html

* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::checkRedirectionCrossOriginAccessControl):
* platform/network/HTTPHeaderNames.in:
* platform/network/ResourceRequestBase.cpp:
(WebCore::shouldUseGet):
(WebCore::ResourceRequestBase::redirectAsGETIfNeeded):
(WebCore::ResourceRequestBase::redirectedRequest const):
* platform/network/ResourceRequestBase.h:

LayoutTests:

Add platform expectations for redirect-method.any.html and
redirect-method.any.worker.html. Remove expectations for
already removed tests redirect-method.html and
redirect-method.worker.html.

* platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt: Removed.
* platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-worker-expected.txt: Removed.
* platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt.
* platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt: Renamed from LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt.
* platform/mac-mojave-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt: Added.
* platform/mac-mojave-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt: Added.
* platform/mac-mojave/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt: Added.
* platform/mac-mojave/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt: Added.
* platform/mac/TestExpectations:
* platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-worker-expected.txt: Removed.
* platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt.
* platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (261820 => 261821)


--- trunk/LayoutTests/ChangeLog	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/ChangeLog	2020-05-18 17:52:59 UTC (rev 261821)
@@ -1,3 +1,28 @@
+2020-05-18  Rob Buis  <rb...@igalia.com>
+
+        Remove certain headers when a redirect causes a request method change
+        https://bugs.webkit.org/show_bug.cgi?id=205119
+
+        Reviewed by Youenn Fablet.
+
+        Add platform expectations for redirect-method.any.html and
+        redirect-method.any.worker.html. Remove expectations for
+        already removed tests redirect-method.html and
+        redirect-method.worker.html.
+
+        * platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt: Removed.
+        * platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-worker-expected.txt: Removed.
+        * platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt.
+        * platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt: Renamed from LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt.
+        * platform/mac-mojave-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt: Added.
+        * platform/mac-mojave-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt: Added.
+        * platform/mac-mojave/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt: Added.
+        * platform/mac-mojave/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt: Added.
+        * platform/mac/TestExpectations:
+        * platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-worker-expected.txt: Removed.
+        * platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt.
+        * platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt.
+
 2020-05-18  Antti Koivisto  <an...@apple.com>
 
         [Wheel event region] Invalidation for root style

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-05-18 17:52:59 UTC (rev 261821)
@@ -1,3 +1,50 @@
+2020-05-18  Rob Buis  <rb...@igalia.com>
+
+        Remove certain headers when a redirect causes a request method change
+        https://bugs.webkit.org/show_bug.cgi?id=205119
+
+        Reviewed by Youenn Fablet.
+
+        Sync fetch/api/redirect (ba2e4f92).
+
+        * resources/import-expectations.json:
+        * web-platform-tests/fetch/api/redirect/redirect-count.any.js:
+        (redirectCount):
+        * web-platform-tests/fetch/api/redirect/redirect-empty-location.any.js:
+        * web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any-expected.txt: Added.
+        * web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.html: Added.
+        * web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.js: Added.
+        (redirectLocation):
+        * web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.worker-expected.txt: Added.
+        * web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.worker.html: Added.
+        * web-platform-tests/fetch/api/redirect/redirect-location.any.js:
+        (redirectLocation):
+        * web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt:
+        * web-platform-tests/fetch/api/redirect/redirect-method.any.js:
+        (redirectMethod):
+        * web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt:
+        * web-platform-tests/fetch/api/redirect/redirect-mode.any.js:
+        (testRedirect):
+        * web-platform-tests/fetch/api/redirect/redirect-origin.any-expected.txt:
+        * web-platform-tests/fetch/api/redirect/redirect-origin.any.js:
+        (testOriginAfterRedirection):
+        * web-platform-tests/fetch/api/redirect/redirect-origin.any.worker-expected.txt:
+        * web-platform-tests/fetch/api/redirect/redirect-referrer.any.js:
+        * web-platform-tests/fetch/api/redirect/redirect-schemes.html:
+        * web-platform-tests/fetch/api/redirect/redirect-to-dataurl.any.js:
+        (redirectDataURL):
+        * web-platform-tests/fetch/api/redirect/w3c-import.log:
+        * web-platform-tests/fetch/api/resources/keepalive-iframe.html:
+        * web-platform-tests/fetch/api/resources/method.py:
+        (main):
+        * web-platform-tests/fetch/api/resources/preflight.py:
+        (main):
+        * web-platform-tests/fetch/api/resources/redirect.py:
+        (main):
+        * web-platform-tests/fetch/api/resources/stash-put.py:
+        (main):
+        * web-platform-tests/fetch/api/resources/trickle.py:
+
 2020-05-15  Oriol Brufau  <obru...@igalia.com>
 
         [css-grid] Treat percentages as auto for the minimum contribution

Modified: trunk/LayoutTests/imported/w3c/resources/import-expectations.json (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/resources/import-expectations.json	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/resources/import-expectations.json	2020-05-18 17:52:59 UTC (rev 261821)
@@ -187,6 +187,8 @@
     "web-platform-tests/fetch": "import", 
     "web-platform-tests/fetch/api": "import", 
     "web-platform-tests/fetch/api/cors": "import", 
+    "web-platform-tests/fetch/api/redirect": "import", 
+    "web-platform-tests/fetch/api/resources": "import", 
     "web-platform-tests/fetch/origin": "import", 
     "web-platform-tests/fetch/range": "import", 
     "web-platform-tests/fetch/stale-while-revalidate": "import", 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count.any.js (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count.any.js	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count.any.js	2020-05-18 17:52:59 UTC (rev 261821)
@@ -19,7 +19,7 @@
       assert_equals(resp.status, 200, "Clean stash response's status is 200");
 
       if (!shouldPass)
-        return promise_rejects(test, new TypeError(), fetch(url + urlParameters, requestInit));
+        return promise_rejects_js(test, TypeError, fetch(url + urlParameters, requestInit));
 
       return fetch(url + urlParameters, requestInit).then(function(resp) {
         assert_equals(resp.status, 200, "Response's status is 200");

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-empty-location.any.js (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-empty-location.any.js	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-empty-location.any.js	2020-05-18 17:52:59 UTC (rev 261821)
@@ -6,7 +6,7 @@
 const url = "" + 'redirect-empty-location.py';
 
 promise_test(t => {
-  return promise_rejects(t, new TypeError(), fetch(url, {redirect:'follow'}));
+  return promise_rejects_js(t, TypeError, fetch(url, {redirect:'follow'}));
 }, 'redirect response with empty Location, follow mode');
 
 promise_test(t => {

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any-expected.txt (0 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1,7 @@
+
+PASS Redirect to escaped UTF-8 
+PASS Redirect to unescaped UTF-8 
+PASS Redirect to escaped and unescaped UTF-8 
+PASS Escaping produces double-percent 
+PASS Redirect to invalid UTF-8 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.html (0 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.html	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.js (0 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.js	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.js	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1,45 @@
+// META: script=../resources/utils.js
+
+// See https://github.com/whatwg/fetch/issues/883 for the behavior covered by
+// this test. As of writing, the Fetch spec has not been updated to cover these.
+
+// redirectLocation tests that a Location header of |locationHeader| is resolved
+// to a URL which ends in |expectedUrlSuffix|. |locationHeader| is interpreted
+// as a byte sequence via isomorphic encode, as described in [INFRA]. This
+// allows the caller to specify byte sequences which are not valid UTF-8.
+// However, this means, e.g., U+2603 must be passed in as "\xe2\x98\x83", its
+// UTF-8 encoding, not "\u2603".
+//
+// [INFRA] https://infra.spec.whatwg.org/#isomorphic-encode
+function redirectLocation(
+    desc, redirectUrl, locationHeader, expectedUrlSuffix) {
+  promise_test(function(test) {
+    // Note we use escape() instead of encodeURIComponent(), so that characters
+    // are escaped as bytes in the isomorphic encoding.
+    var url = "" + '?simple=1&location=' + escape(locationHeader);
+
+    return fetch(url, {'redirect': 'follow'}).then(function(resp) {
+      assert_true(
+          resp.url.endsWith(expectedUrlSuffix),
+          resp.url + ' ends with ' + expectedUrlSuffix);
+    });
+  }, desc);
+}
+
+var redirUrl = RESOURCES_DIR + 'redirect.py';
+redirectLocation(
+    'Redirect to escaped UTF-8', redirUrl, 'top.txt?%E2%98%83%e2%98%83',
+    'top.txt?%E2%98%83%e2%98%83');
+redirectLocation(
+    'Redirect to unescaped UTF-8', redirUrl, 'top.txt?\xe2\x98\x83',
+    'top.txt?%E2%98%83');
+redirectLocation(
+    'Redirect to escaped and unescaped UTF-8', redirUrl,
+    'top.txt?\xe2\x98\x83%e2%98%83', 'top.txt?%E2%98%83%e2%98%83');
+redirectLocation(
+    'Escaping produces double-percent', redirUrl, 'top.txt?%\xe2\x98\x83',
+    'top.txt?%%E2%98%83');
+redirectLocation(
+    'Redirect to invalid UTF-8', redirUrl, 'top.txt?\xff', 'top.txt?%FF');
+
+done();

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.worker-expected.txt (0 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.worker-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.worker-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1,7 @@
+
+PASS Redirect to escaped UTF-8 
+PASS Redirect to unescaped UTF-8 
+PASS Redirect to escaped and unescaped UTF-8 
+PASS Escaping produces double-percent 
+PASS Redirect to invalid UTF-8 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.worker.html (0 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.worker.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.worker.html	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location.any.js (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location.any.js	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location.any.js	2020-05-18 17:52:59 UTC (rev 261821)
@@ -10,7 +10,7 @@
 
   promise_test(function(test) {
     if (redirectMode === "error" || !shouldPass)
-      return promise_rejects(test, new TypeError(), fetch(url + urlParameters, requestInit));
+      return promise_rejects_js(test, TypeError, fetch(url + urlParameters, requestInit));
     if (redirectMode === "manual")
       return fetch(url + urlParameters, requestInit).then(function(resp) {
         assert_equals(resp.status, 0, "Response's status is 0");

Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -1,16 +0,0 @@
-
-PASS Response.redirected should be false on not-redirected responses 
-PASS Redirect 301 with GET 
-PASS Redirect 301 with POST 
-PASS Redirect 301 with HEAD 
-PASS Redirect 302 with GET 
-PASS Redirect 302 with POST 
-PASS Redirect 302 with HEAD 
-PASS Redirect 303 with GET 
-PASS Redirect 303 with POST 
-PASS Redirect 303 with HEAD 
-PASS Redirect 307 with GET 
-PASS Redirect 307 with POST (string body) 
-PASS Redirect 307 with POST (blob body) 
-PASS Redirect 307 with HEAD 
-

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -2,15 +2,16 @@
 PASS Response.redirected should be false on not-redirected responses 
 PASS Redirect 301 with GET 
 PASS Redirect 301 with POST 
-PASS Redirect 301 with HEAD 
+FAIL Redirect 301 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
 PASS Redirect 302 with GET 
 PASS Redirect 302 with POST 
-PASS Redirect 302 with HEAD 
+FAIL Redirect 302 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
 PASS Redirect 303 with GET 
 PASS Redirect 303 with POST 
-PASS Redirect 303 with HEAD 
+FAIL Redirect 303 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 303 with TESTING 
 PASS Redirect 307 with GET 
 PASS Redirect 307 with POST (string body) 
 PASS Redirect 307 with POST (blob body) 
-PASS Redirect 307 with HEAD 
+FAIL Redirect 307 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.js (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.js	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.js	2020-05-18 17:52:59 UTC (rev 261821)
@@ -7,28 +7,70 @@
 // |opts.expectedBodyAsString|: the expected response body as a string. The
 // server is expected to echo the request body. The default is the empty string
 // if the request after redirection isn't POST; otherwise it's |opts.body|.
+// |opts.expectedRequestContentType|: the expected Content-Type of redirected
+// request.
 function redirectMethod(desc, redirectUrl, redirectLocation, redirectStatus, method, expectedMethod, opts) {
-  var url = ""
-  var urlParameters = "?redirect_status=" + redirectStatus;
+  let url = ""
+  let urlParameters = "?redirect_status=" + redirectStatus;
   urlParameters += "&location=" + encodeURIComponent(redirectLocation);
 
-  var requestInit = {"method": method, "redirect": "follow"};
+  let requestHeaders = {
+    "Content-Encoding": "Identity",
+    "Content-Language": "en-US",
+    "Content-Location": "foo",
+  };
+  let requestInit = {"method": method, "redirect": "follow", "headers" : requestHeaders};
   opts = opts || {};
-  if (opts.body)
+  if (opts.body) {
     requestInit.body = opts.body;
+  }
 
   promise_test(function(test) {
     return fetch(url + urlParameters, requestInit).then(function(resp) {
+      let expectedRequestContentType = "NO";
+      if (opts.expectedRequestContentType) {
+        expectedRequestContentType = opts.expectedRequestContentType;
+      }
+
       assert_equals(resp.status, 200, "Response's status is 200");
       assert_equals(resp.type, "basic", "Response's type basic");
-      assert_equals(resp.headers.get("x-request-method"), expectedMethod, "Request method after redirection is " + expectedMethod);
+      assert_equals(
+        resp.headers.get("x-request-method"),
+        expectedMethod,
+        "Request method after redirection is " + expectedMethod);
+      let hasRequestBodyHeader = true;
+      if (opts.expectedStripRequestBodyHeader) {
+        hasRequestBodyHeader = !opts.expectedStripRequestBodyHeader;
+      }
+      assert_equals(
+        resp.headers.get("x-request-content-type"),
+        expectedRequestContentType,
+        "Request Content-Type after redirection is " + expectedRequestContentType);
+      [
+        "Content-Encoding",
+        "Content-Language",
+        "Content-Location"
+      ].forEach(header => {
+        let xHeader = "x-request-" + header.toLowerCase();
+        let expectedValue = hasRequestBodyHeader ? requestHeaders[header] : "NO";
+        assert_equals(
+          resp.headers.get(xHeader),
+          expectedValue,
+          "Request " + header + " after redirection is " + expectedValue);
+      });
       assert_true(resp.redirected);
       return resp.text().then(function(text) {
         let expectedBody = "";
-        if (expectedMethod == "POST")
+        if (expectedMethod == "POST") {
           expectedBody = opts.expectedBodyAsString || requestInit.body;
+        }
+        let expectedContentLength = expectedBody ? expectedBody.length.toString() : "NO";
         assert_equals(text, expectedBody, "request body");
-      });
+        assert_equals(
+          resp.headers.get("x-request-content-length"),
+          expectedContentLength,
+          "Request Content-Length after redirection is " + expectedContentLength);
+        });
     });
   }, desc);
 }
@@ -49,19 +91,20 @@
 const blobBodyAsString = "it's me the blob! and more blob!";
 
 redirectMethod("Redirect 301 with GET", redirUrl, locationUrl, 301, "GET", "GET");
-redirectMethod("Redirect 301 with POST", redirUrl, locationUrl, 301, "POST", "GET", { body: stringBody });
+redirectMethod("Redirect 301 with POST", redirUrl, locationUrl, 301, "POST", "GET", { body: stringBody, expectedStripRequestBodyHeader: true });
 redirectMethod("Redirect 301 with HEAD", redirUrl, locationUrl, 301, "HEAD", "HEAD");
 
 redirectMethod("Redirect 302 with GET", redirUrl, locationUrl, 302, "GET", "GET");
-redirectMethod("Redirect 302 with POST", redirUrl, locationUrl, 302, "POST", "GET", { body: stringBody });
+redirectMethod("Redirect 302 with POST", redirUrl, locationUrl, 302, "POST", "GET", { body: stringBody, expectedStripRequestBodyHeader: true });
 redirectMethod("Redirect 302 with HEAD", redirUrl, locationUrl, 302, "HEAD", "HEAD");
 
 redirectMethod("Redirect 303 with GET", redirUrl, locationUrl, 303, "GET", "GET");
-redirectMethod("Redirect 303 with POST", redirUrl, locationUrl, 303, "POST", "GET", { body: stringBody });
+redirectMethod("Redirect 303 with POST", redirUrl, locationUrl, 303, "POST", "GET", { body: stringBody, expectedStripRequestBodyHeader: true });
 redirectMethod("Redirect 303 with HEAD", redirUrl, locationUrl, 303, "HEAD", "HEAD");
+redirectMethod("Redirect 303 with TESTING", redirUrl, locationUrl, 303, "TESTING", "GET", { expectedStripRequestBodyHeader: true });
 
 redirectMethod("Redirect 307 with GET", redirUrl, locationUrl, 307, "GET", "GET");
-redirectMethod("Redirect 307 with POST (string body)", redirUrl, locationUrl, 307, "POST", "POST", { body: stringBody });
+redirectMethod("Redirect 307 with POST (string body)", redirUrl, locationUrl, 307, "POST", "POST", { body: stringBody , expectedRequestContentType: "text/plain;charset=UTF-8"});
 redirectMethod("Redirect 307 with POST (blob body)", redirUrl, locationUrl, 307, "POST", "POST", { body: blobBody, expectedBodyAsString: blobBodyAsString });
 redirectMethod("Redirect 307 with HEAD", redirUrl, locationUrl, 307, "HEAD", "HEAD");
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -2,15 +2,16 @@
 PASS Response.redirected should be false on not-redirected responses 
 PASS Redirect 301 with GET 
 PASS Redirect 301 with POST 
-PASS Redirect 301 with HEAD 
+FAIL Redirect 301 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
 PASS Redirect 302 with GET 
 PASS Redirect 302 with POST 
-PASS Redirect 302 with HEAD 
+FAIL Redirect 302 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
 PASS Redirect 303 with GET 
 PASS Redirect 303 with POST 
-PASS Redirect 303 with HEAD 
+FAIL Redirect 303 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 303 with TESTING 
 PASS Redirect 307 with GET 
 PASS Redirect 307 with POST (string body) 
 PASS Redirect 307 with POST (blob body) 
-PASS Redirect 307 with HEAD 
+FAIL Redirect 307 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-mode.any.js (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-mode.any.js	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-mode.any.js	2020-05-18 17:52:59 UTC (rev 261821)
@@ -17,7 +17,7 @@
   promise_test(function(test) {
     if (redirectMode === "error" ||
         (corsMode === "no-cors" && redirectMode !== "follow" && origin !== "same-origin"))
-      return promise_rejects(test, new TypeError(), fetch(url + urlParameters, requestInit));
+      return promise_rejects_js(test, TypeError, fetch(url + urlParameters, requestInit));
     if (redirectMode === "manual")
       return fetch(url + urlParameters, requestInit).then(function(resp) {
         assert_equals(resp.status, 0, "Response's status is 0");

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-origin.any-expected.txt (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-origin.any-expected.txt	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-origin.any-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -3,20 +3,40 @@
 PASS Same origin to other origin redirection 301 
 PASS Other origin to other origin redirection 301 
 PASS Other origin to same origin redirection 301 
+PASS Same origin to same origin redirection[POST] 301 
+PASS Same origin to other origin redirection[POST] 301 
+PASS Other origin to other origin redirection[POST] 301 
+PASS Other origin to same origin redirection[POST] 301 
 PASS Same origin to same origin redirection 302 
 PASS Same origin to other origin redirection 302 
 PASS Other origin to other origin redirection 302 
 PASS Other origin to same origin redirection 302 
+PASS Same origin to same origin redirection[POST] 302 
+PASS Same origin to other origin redirection[POST] 302 
+PASS Other origin to other origin redirection[POST] 302 
+PASS Other origin to same origin redirection[POST] 302 
 PASS Same origin to same origin redirection 303 
 PASS Same origin to other origin redirection 303 
 PASS Other origin to other origin redirection 303 
 PASS Other origin to same origin redirection 303 
+PASS Same origin to same origin redirection[POST] 303 
+PASS Same origin to other origin redirection[POST] 303 
+PASS Other origin to other origin redirection[POST] 303 
+PASS Other origin to same origin redirection[POST] 303 
 PASS Same origin to same origin redirection 307 
 PASS Same origin to other origin redirection 307 
 PASS Other origin to other origin redirection 307 
 PASS Other origin to same origin redirection 307 
+PASS Same origin to same origin redirection[POST] 307 
+PASS Same origin to other origin redirection[POST] 307 
+PASS Other origin to other origin redirection[POST] 307 
+PASS Other origin to same origin redirection[POST] 307 
 PASS Same origin to same origin redirection 308 
 PASS Same origin to other origin redirection 308 
 PASS Other origin to other origin redirection 308 
 PASS Other origin to same origin redirection 308 
+PASS Same origin to same origin redirection[POST] 308 
+PASS Same origin to other origin redirection[POST] 308 
+PASS Other origin to other origin redirection[POST] 308 
+PASS Other origin to same origin redirection[POST] 308 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-origin.any.js (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-origin.any.js	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-origin.any.js	2020-05-18 17:52:59 UTC (rev 261821)
@@ -2,7 +2,7 @@
 // META: script=../resources/utils.js
 // META: script=/common/get-host-info.sub.js
 
-function testOriginAfterRedirection(desc, redirectUrl, redirectLocation, redirectStatus, expectedOrigin) {
+function testOriginAfterRedirection(desc, method, redirectUrl, redirectLocation, redirectStatus, expectedOrigin) {
     var uuid_token = token();
     var url = ""
     var urlParameters = "?token=" + uuid_token + "&max_age=0";
@@ -28,10 +28,15 @@
 var corsLocationUrl =  get_host_info().HTTP_REMOTE_ORIGIN + dirname(location.pathname) + RESOURCES_DIR + "inspect-headers.py?cors&headers=origin";
 
 for (var code of [301, 302, 303, 307, 308]) {
-    testOriginAfterRedirection("Same origin to same origin redirection " + code, redirectUrl, locationUrl, code, null);
-    testOriginAfterRedirection("Same origin to other origin redirection " + code, redirectUrl, corsLocationUrl, code, get_host_info().HTTP_ORIGIN);
-    testOriginAfterRedirection("Other origin to other origin redirection " + code, corsRedirectUrl, corsLocationUrl, code, get_host_info().HTTP_ORIGIN);
-    testOriginAfterRedirection("Other origin to same origin redirection " + code, corsRedirectUrl, locationUrl + "&cors", code, "null");
+    testOriginAfterRedirection("Same origin to same origin redirection " + code, 'GET', redirectUrl, locationUrl, code, null);
+    testOriginAfterRedirection("Same origin to other origin redirection " + code, 'GET', redirectUrl, corsLocationUrl, code, get_host_info().HTTP_ORIGIN);
+    testOriginAfterRedirection("Other origin to other origin redirection " + code, 'GET', corsRedirectUrl, corsLocationUrl, code, get_host_info().HTTP_ORIGIN);
+    testOriginAfterRedirection("Other origin to same origin redirection " + code, 'GET', corsRedirectUrl, locationUrl + "&cors", code, "null");
+
+    testOriginAfterRedirection("Same origin to same origin redirection[POST] " + code, 'POST', redirectUrl, locationUrl, code, null);
+    testOriginAfterRedirection("Same origin to other origin redirection[POST] " + code, 'POST', redirectUrl, corsLocationUrl, code, get_host_info().HTTP_ORIGIN);
+    testOriginAfterRedirection("Other origin to other origin redirection[POST] " + code, 'POST', corsRedirectUrl, corsLocationUrl, code, get_host_info().HTTP_ORIGIN);
+    testOriginAfterRedirection("Other origin to same origin redirection[POST] " + code, 'POST', corsRedirectUrl, locationUrl + "&cors", code, "null");
 }
 
 done();

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-origin.any.worker-expected.txt (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-origin.any.worker-expected.txt	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-origin.any.worker-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -3,20 +3,40 @@
 PASS Same origin to other origin redirection 301 
 PASS Other origin to other origin redirection 301 
 PASS Other origin to same origin redirection 301 
+PASS Same origin to same origin redirection[POST] 301 
+PASS Same origin to other origin redirection[POST] 301 
+PASS Other origin to other origin redirection[POST] 301 
+PASS Other origin to same origin redirection[POST] 301 
 PASS Same origin to same origin redirection 302 
 PASS Same origin to other origin redirection 302 
 PASS Other origin to other origin redirection 302 
 PASS Other origin to same origin redirection 302 
+PASS Same origin to same origin redirection[POST] 302 
+PASS Same origin to other origin redirection[POST] 302 
+PASS Other origin to other origin redirection[POST] 302 
+PASS Other origin to same origin redirection[POST] 302 
 PASS Same origin to same origin redirection 303 
 PASS Same origin to other origin redirection 303 
 PASS Other origin to other origin redirection 303 
 PASS Other origin to same origin redirection 303 
+PASS Same origin to same origin redirection[POST] 303 
+PASS Same origin to other origin redirection[POST] 303 
+PASS Other origin to other origin redirection[POST] 303 
+PASS Other origin to same origin redirection[POST] 303 
 PASS Same origin to same origin redirection 307 
 PASS Same origin to other origin redirection 307 
 PASS Other origin to other origin redirection 307 
 PASS Other origin to same origin redirection 307 
+PASS Same origin to same origin redirection[POST] 307 
+PASS Same origin to other origin redirection[POST] 307 
+PASS Other origin to other origin redirection[POST] 307 
+PASS Other origin to same origin redirection[POST] 307 
 PASS Same origin to same origin redirection 308 
 PASS Same origin to other origin redirection 308 
 PASS Other origin to other origin redirection 308 
 PASS Other origin to same origin redirection 308 
+PASS Same origin to same origin redirection[POST] 308 
+PASS Same origin to other origin redirection[POST] 308 
+PASS Other origin to other origin redirection[POST] 308 
+PASS Other origin to same origin redirection[POST] 308 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-referrer.any.js (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-referrer.any.js	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-referrer.any.js	2020-05-18 17:52:59 UTC (rev 261821)
@@ -1,3 +1,4 @@
+// META: timeout=long
 // META: script=/common/utils.js
 // META: script=../resources/utils.js
 // META: script=/common/get-host-info.sub.js

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-schemes.html (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-schemes.html	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-schemes.html	2020-05-18 17:52:59 UTC (rev 261821)
@@ -17,7 +17,7 @@
   ];
   tests.forEach(function(url) {
     promise_test(function(test) {
-      return promise_rejects(test, new TypeError(), fetch(url))
+      return promise_rejects_js(test, TypeError, fetch(url))
     })
   })
 </script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-to-dataurl.any.js (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-to-dataurl.any.js	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-to-dataurl.any.js	2020-05-18 17:52:59 UTC (rev 261821)
@@ -10,7 +10,7 @@
     var requestInit = {"mode": mode};
 
     promise_test(function(test) {
-        return promise_rejects(test, new TypeError(), fetch(url, requestInit));
+        return promise_rejects_js(test, TypeError, fetch(url, requestInit));
     }, desc);
 }
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/w3c-import.log (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/w3c-import.log	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/w3c-import.log	2020-05-18 17:52:59 UTC (rev 261821)
@@ -17,6 +17,7 @@
 /LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-back-to-original-origin.any.js
 /LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count.any.js
 /LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-empty-location.any.js
+/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-escape.tentative.any.js
 /LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location.any.js
 /LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.js
 /LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-mode.any.js

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/keepalive-iframe.html (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/keepalive-iframe.html	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/keepalive-iframe.html	2020-05-18 17:52:59 UTC (rev 261821)
@@ -2,16 +2,24 @@
 <html>
 <meta charset="utf-8">
 <script src=""
+<script src=""
 <script>
-const uuid = token();
-const URL =
-    `../resources/redirect.py?` +
-    `delay=100&` +
-    `location=../resources/stash-put.py?key=${uuid}%26value=on`;
+const SEARCH_PARAMS = new URL(location.href).searchParams;
+const ORIGIN1 = SEARCH_PARAMS.get('origin1') || '';
+const ORIGIN2 = SEARCH_PARAMS.get('origin2') || '';
+const WITH_HEADERS = !!SEARCH_PARAMS.has('with-headers');
+const TOKEN = token();
 
+const url =
+    `${ORIGIN1}/fetch/api/resources/redirect.py?` +
+    `delay=500&` +
+    `allow_headers=foo&` +
+    `location=${ORIGIN2}/fetch/api/resources/stash-put.py?key=${TOKEN}%26value=on`;
+
 addEventListener('load', () => {
-  let p = fetch(URL, {keepalive: true});
-  window.parent.postMessage(uuid, '*');
+  const headers = WITH_HEADERS ? {'foo': 'bar'} : undefined;
+  let p = fetch(url, {keepalive: true, headers});
+  window.parent.postMessage(TOKEN, '*');
 });
 </script>
 </html>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/method.py (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/method.py	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/method.py	2020-05-18 17:52:59 UTC (rev 261821)
@@ -8,4 +8,9 @@
         headers.append(("Access-Control-Expose-Headers", "x-request-method"))
 
     headers.append(("x-request-method", request.method))
+    headers.append(("x-request-content-type", request.headers.get("Content-Type", "NO")))
+    headers.append(("x-request-content-length", request.headers.get("Content-Length", "NO")))
+    headers.append(("x-request-content-encoding", request.headers.get("Content-Encoding", "NO")))
+    headers.append(("x-request-content-language", request.headers.get("Content-Language", "NO")))
+    headers.append(("x-request-content-location", request.headers.get("Content-Location", "NO")))
     return headers, request.body

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/preflight.py (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/preflight.py	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/preflight.py	2020-05-18 17:52:59 UTC (rev 261821)
@@ -26,6 +26,10 @@
             response.set_error(400, "No Access-Control-Request-Method header")
             return "ERROR: No access-control-request-method in preflight!"
 
+        if request.headers.get("Accept", "") != "*/*":
+            response.set_error(400, "Request does not have 'Accept: */*' header")
+            return "ERROR: Invalid access in preflight!"
+
         if "control_request_headers" in request.GET:
             stashed_data['control_request_headers'] = request.headers.get("Access-Control-Request-Headers", None)
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/redirect.py (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/redirect.py	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/redirect.py	2020-05-18 17:52:59 UTC (rev 261821)
@@ -1,7 +1,7 @@
-from urllib import urlencode
-from urlparse import urlparse
 import time
 
+from six.moves.urllib.parse import urlencode, urlparse
+
 def main(request, response):
     stashed_data = {'count': 0, 'preflight': "0"}
     status = 302
@@ -38,16 +38,17 @@
 
     if "location" in request.GET:
         url = ""
-        scheme = urlparse(url).scheme
-        if scheme == "" or scheme == "http" or scheme == "https":
-            url += "&" if '?' in url else "?"
-            #keep url parameters in location
-            url_parameters = {}
-            for item in request.GET.items():
-                url_parameters[item[0]] = item[1][0]
-            url += urlencode(url_parameters)
-            #make sure location changes during redirection loop
-            url += "&count=" + str(stashed_data['count'])
+        if "simple" not in request.GET:
+            scheme = urlparse(url).scheme
+            if scheme == "" or scheme == "http" or scheme == "https":
+                url += "&" if '?' in url else "?"
+                #keep url parameters in location
+                url_parameters = {}
+                for item in request.GET.items():
+                    url_parameters[item[0]] = item[1][0]
+                url += urlencode(url_parameters)
+                #make sure location changes during redirection loop
+                url += "&count=" + str(stashed_data['count'])
         headers.append(("Location", url))
 
     if "redirect_referrerpolicy" in request.GET:

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/stash-put.py (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/stash-put.py	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/stash-put.py	2020-05-18 17:52:59 UTC (rev 261821)
@@ -1,4 +1,11 @@
 def main(request, response):
+    if request.method == 'OPTIONS':
+        # CORS preflight
+        response.headers.set('Access-Control-Allow-Origin', '*')
+        response.headers.set('Access-Control-Allow-Methods', '*')
+        response.headers.set('Access-Control-Allow-Headers', '*')
+        return 'done'
+
     url_dir = '/'.join(request.url_parts.path.split('/')[:-1]) + '/'
     key = request.GET.first("key")
     value = request.GET.first("value")

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/trickle.py (261820 => 261821)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/trickle.py	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/trickle.py	2020-05-18 17:52:59 UTC (rev 261821)
@@ -1,5 +1,7 @@
 import time
 
+from six.moves import xrange
+
 def main(request, response):
     delay = float(request.GET.first("ms", 500)) / 1E3
     count = int(request.GET.first("count", 50))

Deleted: trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt (261820 => 261821)


--- trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -1,15 +0,0 @@
-
-PASS Response.redirected should be false on not-redirected responses 
-PASS Redirect 301 with GET 
-PASS Redirect 301 with POST 
-PASS Redirect 301 with HEAD 
-PASS Redirect 302 with GET 
-PASS Redirect 302 with POST 
-PASS Redirect 302 with HEAD 
-PASS Redirect 303 with GET 
-PASS Redirect 303 with POST 
-PASS Redirect 303 with HEAD 
-PASS Redirect 307 with GET 
-PASS Redirect 307 with POST 
-PASS Redirect 307 with HEAD 
-

Deleted: trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-worker-expected.txt (261820 => 261821)


--- trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-worker-expected.txt	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-worker-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -1,15 +0,0 @@
-
-PASS Response.redirected should be false on not-redirected responses 
-PASS Redirect 301 with GET 
-PASS Redirect 301 with POST 
-PASS Redirect 301 with HEAD 
-PASS Redirect 302 with GET 
-PASS Redirect 302 with POST 
-PASS Redirect 302 with HEAD 
-PASS Redirect 303 with GET 
-PASS Redirect 303 with POST 
-PASS Redirect 303 with HEAD 
-PASS Redirect 307 with GET 
-PASS Redirect 307 with POST 
-PASS Redirect 307 with HEAD 
-

Copied: trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt (from rev 261820, trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt) (0 => 261821)


--- trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1,17 @@
+
+PASS Response.redirected should be false on not-redirected responses 
+PASS Redirect 301 with GET 
+PASS Redirect 301 with POST 
+PASS Redirect 301 with HEAD 
+PASS Redirect 302 with GET 
+PASS Redirect 302 with POST 
+PASS Redirect 302 with HEAD 
+PASS Redirect 303 with GET 
+PASS Redirect 303 with POST 
+PASS Redirect 303 with HEAD 
+PASS Redirect 303 with TESTING 
+PASS Redirect 307 with GET 
+PASS Redirect 307 with POST (string body) 
+PASS Redirect 307 with POST (blob body) 
+PASS Redirect 307 with HEAD 
+

Copied: trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt (from rev 261820, trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt) (0 => 261821)


--- trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1,17 @@
+
+PASS Response.redirected should be false on not-redirected responses 
+PASS Redirect 301 with GET 
+PASS Redirect 301 with POST 
+PASS Redirect 301 with HEAD 
+PASS Redirect 302 with GET 
+PASS Redirect 302 with POST 
+PASS Redirect 302 with HEAD 
+PASS Redirect 303 with GET 
+PASS Redirect 303 with POST 
+PASS Redirect 303 with HEAD 
+PASS Redirect 303 with TESTING 
+PASS Redirect 307 with GET 
+PASS Redirect 307 with POST (string body) 
+PASS Redirect 307 with POST (blob body) 
+PASS Redirect 307 with HEAD 
+

Modified: trunk/LayoutTests/platform/mac/TestExpectations (261820 => 261821)


--- trunk/LayoutTests/platform/mac/TestExpectations	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2020-05-18 17:52:59 UTC (rev 261821)
@@ -366,10 +366,6 @@
 editing/mac/pasteboard/dataTransfer-set-data-file-url.html [ Skip ]
 webkit.org/b/147674 editing/mac/pasteboard/5583362.html [ Skip ]
 
-# Assorted failures that need investigation
-[ Debug ] imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker.html [ Skip ]
-[ Debug ] imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.html [ Skip ]
-
 webkit.org/b/107118 fast/canvas/canvas-quadratic-same-endpoint.html [ Failure ]
 webkit.org/b/142258 fast/css/object-fit/object-fit-canvas.html [ Pass ImageOnlyFailure ]
 

Added: trunk/LayoutTests/platform/mac-mojave/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt (0 => 261821)


--- trunk/LayoutTests/platform/mac-mojave/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mojave/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1,17 @@
+
+PASS Response.redirected should be false on not-redirected responses 
+PASS Redirect 301 with GET 
+PASS Redirect 301 with POST 
+FAIL Redirect 301 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 302 with GET 
+PASS Redirect 302 with POST 
+FAIL Redirect 302 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 303 with GET 
+PASS Redirect 303 with POST 
+FAIL Redirect 303 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 303 with TESTING 
+PASS Redirect 307 with GET 
+PASS Redirect 307 with POST (string body) 
+FAIL Redirect 307 with POST (blob body) assert_equals: Request Content-Type after redirection is NO expected "NO" but got "application/x-www-form-urlencoded"
+FAIL Redirect 307 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+

Added: trunk/LayoutTests/platform/mac-mojave/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt (0 => 261821)


--- trunk/LayoutTests/platform/mac-mojave/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mojave/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1,17 @@
+
+PASS Response.redirected should be false on not-redirected responses 
+PASS Redirect 301 with GET 
+PASS Redirect 301 with POST 
+FAIL Redirect 301 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 302 with GET 
+PASS Redirect 302 with POST 
+FAIL Redirect 302 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 303 with GET 
+PASS Redirect 303 with POST 
+FAIL Redirect 303 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 303 with TESTING 
+PASS Redirect 307 with GET 
+PASS Redirect 307 with POST (string body) 
+FAIL Redirect 307 with POST (blob body) assert_equals: Request Content-Type after redirection is NO expected "NO" but got "application/x-www-form-urlencoded"
+FAIL Redirect 307 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+

Added: trunk/LayoutTests/platform/mac-mojave-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt (0 => 261821)


--- trunk/LayoutTests/platform/mac-mojave-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mojave-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1,17 @@
+
+PASS Response.redirected should be false on not-redirected responses 
+PASS Redirect 301 with GET 
+PASS Redirect 301 with POST 
+FAIL Redirect 301 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 302 with GET 
+PASS Redirect 302 with POST 
+FAIL Redirect 302 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 303 with GET 
+PASS Redirect 303 with POST 
+FAIL Redirect 303 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 303 with TESTING 
+PASS Redirect 307 with GET 
+PASS Redirect 307 with POST (string body) 
+PASS Redirect 307 with POST (blob body) 
+FAIL Redirect 307 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+

Added: trunk/LayoutTests/platform/mac-mojave-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt (0 => 261821)


--- trunk/LayoutTests/platform/mac-mojave-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mojave-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1,17 @@
+
+PASS Response.redirected should be false on not-redirected responses 
+PASS Redirect 301 with GET 
+PASS Redirect 301 with POST 
+FAIL Redirect 301 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 302 with GET 
+PASS Redirect 302 with POST 
+FAIL Redirect 302 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 303 with GET 
+PASS Redirect 303 with POST 
+FAIL Redirect 303 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+PASS Redirect 303 with TESTING 
+PASS Redirect 307 with GET 
+PASS Redirect 307 with POST (string body) 
+PASS Redirect 307 with POST (blob body) 
+FAIL Redirect 307 with HEAD assert_equals: Request Content-Length after redirection is NO expected "NO" but got "0"
+

Deleted: trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt (261820 => 261821)


--- trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -1,16 +0,0 @@
-
-PASS Response.redirected should be false on not-redirected responses 
-PASS Redirect 301 with GET 
-PASS Redirect 301 with POST 
-PASS Redirect 301 with HEAD 
-PASS Redirect 302 with GET 
-PASS Redirect 302 with POST 
-PASS Redirect 302 with HEAD 
-PASS Redirect 303 with GET 
-PASS Redirect 303 with POST 
-PASS Redirect 303 with HEAD 
-PASS Redirect 307 with GET 
-PASS Redirect 307 with POST (string body) 
-FAIL Redirect 307 with POST (blob body) assert_equals: request body expected "it's me the blob! and more blob!" but got ""
-PASS Redirect 307 with HEAD 
-

Deleted: trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-worker-expected.txt (261820 => 261821)


--- trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-worker-expected.txt	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-worker-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -1,16 +0,0 @@
-
-PASS Response.redirected should be false on not-redirected responses 
-PASS Redirect 301 with GET 
-PASS Redirect 301 with POST 
-PASS Redirect 301 with HEAD 
-PASS Redirect 302 with GET 
-PASS Redirect 302 with POST 
-PASS Redirect 302 with HEAD 
-PASS Redirect 303 with GET 
-PASS Redirect 303 with POST 
-PASS Redirect 303 with HEAD 
-PASS Redirect 307 with GET 
-PASS Redirect 307 with POST (string body) 
-FAIL Redirect 307 with POST (blob body) assert_equals: request body expected "it's me the blob! and more blob!" but got ""
-PASS Redirect 307 with HEAD 
-

Copied: trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt (from rev 261820, trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt) (0 => 261821)


--- trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1,17 @@
+
+PASS Response.redirected should be false on not-redirected responses 
+PASS Redirect 301 with GET 
+PASS Redirect 301 with POST 
+PASS Redirect 301 with HEAD 
+PASS Redirect 302 with GET 
+PASS Redirect 302 with POST 
+PASS Redirect 302 with HEAD 
+PASS Redirect 303 with GET 
+PASS Redirect 303 with POST 
+PASS Redirect 303 with HEAD 
+PASS Redirect 303 with TESTING 
+PASS Redirect 307 with GET 
+PASS Redirect 307 with POST (string body) 
+PASS Redirect 307 with POST (blob body) 
+PASS Redirect 307 with HEAD 
+

Copied: trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt (from rev 261820, trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt) (0 => 261821)


--- trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker-expected.txt	2020-05-18 17:52:59 UTC (rev 261821)
@@ -0,0 +1,17 @@
+
+PASS Response.redirected should be false on not-redirected responses 
+PASS Redirect 301 with GET 
+PASS Redirect 301 with POST 
+PASS Redirect 301 with HEAD 
+PASS Redirect 302 with GET 
+PASS Redirect 302 with POST 
+PASS Redirect 302 with HEAD 
+PASS Redirect 303 with GET 
+PASS Redirect 303 with POST 
+PASS Redirect 303 with HEAD 
+PASS Redirect 303 with TESTING 
+PASS Redirect 307 with GET 
+PASS Redirect 307 with POST (string body) 
+PASS Redirect 307 with POST (blob body) 
+PASS Redirect 307 with HEAD 
+

Modified: trunk/Source/WebCore/ChangeLog (261820 => 261821)


--- trunk/Source/WebCore/ChangeLog	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/Source/WebCore/ChangeLog	2020-05-18 17:52:59 UTC (rev 261821)
@@ -1,3 +1,25 @@
+2020-05-18  Rob Buis  <rb...@igalia.com>
+
+        Remove certain headers when a redirect causes a request method change
+        https://bugs.webkit.org/show_bug.cgi?id=205119
+
+        Reviewed by Youenn Fablet.
+
+        Implement step 11 of HTTP-redirect fetch [1] to redirect to GET
+        method, remove body and strip certain headers for 301, 302 and 303 redirects.
+
+        Tests: imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.html
+               imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.any.worker.html
+
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::checkRedirectionCrossOriginAccessControl):
+        * platform/network/HTTPHeaderNames.in:
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::shouldUseGet):
+        (WebCore::ResourceRequestBase::redirectAsGETIfNeeded):
+        (WebCore::ResourceRequestBase::redirectedRequest const):
+        * platform/network/ResourceRequestBase.h:
+
 2020-05-18  Antti Koivisto  <an...@apple.com>
 
         [Wheel event region] Invalidation for root style

Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (261820 => 261821)


--- trunk/Source/WebCore/loader/SubresourceLoader.cpp	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp	2020-05-18 17:52:59 UTC (rev 261821)
@@ -659,6 +659,8 @@
     if (crossOriginFlag && redirectingToNewOrigin)
         m_origin = SecurityOrigin::createUnique();
 
+    newRequest.redirectAsGETIfNeeded(previousRequest, redirectResponse);
+
     // Implementing https://fetch.spec.whatwg.org/#concept-http-redirect-fetch step 14.
     updateReferrerPolicy(redirectResponse.httpHeaderField(HTTPHeaderName::ReferrerPolicy));
 

Modified: trunk/Source/WebCore/platform/network/HTTPHeaderNames.in (261820 => 261821)


--- trunk/Source/WebCore/platform/network/HTTPHeaderNames.in	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/Source/WebCore/platform/network/HTTPHeaderNames.in	2020-05-18 17:52:59 UTC (rev 261821)
@@ -44,6 +44,7 @@
 Content-Encoding
 Content-Language
 Content-Length
+Content-Location
 Content-Security-Policy
 Content-Security-Policy-Report-Only
 Content-Type

Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp (261820 => 261821)


--- trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp	2020-05-18 17:52:59 UTC (rev 261821)
@@ -129,11 +129,27 @@
 
 static bool shouldUseGet(const ResourceRequestBase& request, const ResourceResponse& redirectResponse)
 {
+    if (equalLettersIgnoringASCIICase(request.httpMethod(), "get") || equalLettersIgnoringASCIICase(request.httpMethod(), "head"))
+        return false;
     if (redirectResponse.httpStatusCode() == 301 || redirectResponse.httpStatusCode() == 302)
         return equalLettersIgnoringASCIICase(request.httpMethod(), "post");
     return redirectResponse.httpStatusCode() == 303;
 }
 
+// https://fetch.spec.whatwg.org/#concept-http-redirect-fetch Step 11
+void ResourceRequestBase::redirectAsGETIfNeeded(const ResourceRequestBase &redirectRequest, const ResourceResponse& redirectResponse)
+{
+    if (shouldUseGet(redirectRequest, redirectResponse)) {
+        setHTTPMethod("GET"_s);
+        setHTTPBody(nullptr);
+        m_httpHeaderFields.remove(HTTPHeaderName::ContentLength);
+        m_httpHeaderFields.remove(HTTPHeaderName::ContentLanguage);
+        m_httpHeaderFields.remove(HTTPHeaderName::ContentEncoding);
+        m_httpHeaderFields.remove(HTTPHeaderName::ContentLocation);
+        clearHTTPContentType();
+    }
+}
+
 ResourceRequest ResourceRequestBase::redirectedRequest(const ResourceResponse& redirectResponse, bool shouldClearReferrerOnHTTPSToHTTPRedirect) const
 {
     ASSERT(redirectResponse.isRedirection());
@@ -145,12 +161,7 @@
 
     request.setURL(location.isEmpty() ? URL { } : URL { redirectResponse.url(), location });
 
-    if (shouldUseGet(*this, redirectResponse)) {
-        request.setHTTPMethod("GET"_s);
-        request.setHTTPBody(nullptr);
-        request.clearHTTPContentType();
-        request.m_httpHeaderFields.remove(HTTPHeaderName::ContentLength);
-    }
+    request.redirectAsGETIfNeeded(*this, redirectResponse);
 
     if (shouldClearReferrerOnHTTPSToHTTPRedirect && !request.url().protocolIs("https") && WTF::protocolIs(request.httpReferrer(), "https"))
         request.clearHTTPReferrer();

Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.h (261820 => 261821)


--- trunk/Source/WebCore/platform/network/ResourceRequestBase.h	2020-05-18 17:50:11 UTC (rev 261820)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.h	2020-05-18 17:52:59 UTC (rev 261821)
@@ -67,6 +67,7 @@
     WEBCORE_EXPORT const URL& url() const;
     WEBCORE_EXPORT void setURL(const URL& url);
 
+    void redirectAsGETIfNeeded(const ResourceRequestBase &, const ResourceResponse&);
     WEBCORE_EXPORT ResourceRequest redirectedRequest(const ResourceResponse&, bool shouldClearReferrerOnHTTPSToHTTPRedirect) const;
 
     WEBCORE_EXPORT void removeCredentials();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to