Title: [284139] trunk
Revision
284139
Author
[email protected]
Date
2021-10-13 17:49:17 -0700 (Wed, 13 Oct 2021)

Log Message

HTTP method in web inspector network tab is not what WebKit actually sent after a redirect from POST to GET
https://bugs.webkit.org/show_bug.cgi?id=222558

Source/WebInspectorUI:

Patch by Carlos Garcia Campos <[email protected]> on 2021-10-13
Reviewed by Michael Catanzaro.

Test: http/tests/inspector/network/resource-redirect-request-headers.html

For redirects, use the previous request information combined with the new response information to create a
Redirect record.

* UserInterface/Models/Resource.js:
(WI.Resource.prototype.updateForRedirectResponse):

LayoutTests:

Patch by Patrick Angle <[email protected]> on 2021-10-13
Reviewed by Michael Catanzaro.

Test that redirect requests and responses have the appropriate method and status code and the correct number of
redirect records were created.

* http/tests/inspector/network/resource-redirect-request-headers-expected.txt: Added.
* http/tests/inspector/network/resource-redirect-request-headers.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (284138 => 284139)


--- trunk/LayoutTests/ChangeLog	2021-10-14 00:41:04 UTC (rev 284138)
+++ trunk/LayoutTests/ChangeLog	2021-10-14 00:49:17 UTC (rev 284139)
@@ -1,3 +1,16 @@
+2021-10-13  Patrick Angle  <[email protected]>
+
+        HTTP method in web inspector network tab is not what WebKit actually sent after a redirect from POST to GET
+        https://bugs.webkit.org/show_bug.cgi?id=222558
+
+        Reviewed by Michael Catanzaro.
+
+        Test that redirect requests and responses have the appropriate method and status code and the correct number of
+        redirect records were created.
+
+        * http/tests/inspector/network/resource-redirect-request-headers-expected.txt: Added.
+        * http/tests/inspector/network/resource-redirect-request-headers.html: Added.
+
 2021-10-13  Megan Gardner  <[email protected]>
 
         Remove adjustForIOSCaretWhenScrolling() code

Added: trunk/LayoutTests/http/tests/inspector/network/resource-redirect-request-headers-expected.txt (0 => 284139)


--- trunk/LayoutTests/http/tests/inspector/network/resource-redirect-request-headers-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resource-redirect-request-headers-expected.txt	2021-10-14 00:49:17 UTC (rev 284139)
@@ -0,0 +1,14 @@
+Tests that a resource request's headers have correct information after a redirect.
+
+
+== Running test suite: Resource.Redirect.RequestHeaders
+-- Running test case: Resource.Redirect.RequestHeadersPostToGet
+PASS: Resource final request method should be `GET`.
+PASS: Resource final status code should be `200`.
+PASS: Resource final status text should be `OK`.
+PASS: Resource should have one redirect.
+PASS: Redirected request method should be `POST`
+PASS: Redirected request status code should be `302`.
+PASS: Redirected request status text should be `Found`.
+PASS: Redirected request response should have a location header of `redirect.py`
+

Added: trunk/LayoutTests/http/tests/inspector/network/resource-redirect-request-headers.html (0 => 284139)


--- trunk/LayoutTests/http/tests/inspector/network/resource-redirect-request-headers.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resource-redirect-request-headers.html	2021-10-14 00:49:17 UTC (rev 284139)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script>
+
+function createRedirectRequest() {
+    fetch("resources/delay.py", {
+        method: "POST",
+    });
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Resource.Redirect.RequestHeaders");
+
+    suite.addTestCase({
+        name: "Resource.Redirect.RequestHeadersPostToGet",
+        description: "Check if a POST request redirected to a GET has correct method and location information.",
+        async test() {
+            let [event] = await Promise.all([
+                WI.Resource.awaitEvent(WI.Resource.Event.ResponseReceived),
+                InspectorTest.evaluateInPage(`createRedirectRequest()`),
+            ]);
+
+            let resource = event.target;
+            InspectorTest.expectEqual(resource.requestMethod, "GET", "Resource final request method should be `GET`.");
+            InspectorTest.expectEqual(resource.statusCode, 200, "Resource final status code should be `200`.");
+            InspectorTest.expectEqual(resource.statusText, "OK", "Resource final status text should be `OK`.");
+            InspectorTest.expectEqual(resource.redirects.length, 1, "Resource should have one redirect.");
+
+            let redirect = resource.redirects[0]
+            InspectorTest.expectEqual(redirect.requestMethod, "POST", "Redirected request method should be `POST`");
+            InspectorTest.expectEqual(redirect.responseStatusCode, 302, "Redirected request status code should be `302`.");
+            InspectorTest.expectEqual(redirect.responseStatusText, "Found", "Redirected request status text should be `Found`.");
+            InspectorTest.expectEqual(redirect.responseHeaders["Location"], "redirect.py", "Redirected request response should have a location header of `redirect.py`");
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+    <p>Tests that a resource request's headers have correct information after a redirect.</p>
+</body>
+</html>

Modified: trunk/Source/WebInspectorUI/ChangeLog (284138 => 284139)


--- trunk/Source/WebInspectorUI/ChangeLog	2021-10-14 00:41:04 UTC (rev 284138)
+++ trunk/Source/WebInspectorUI/ChangeLog	2021-10-14 00:49:17 UTC (rev 284139)
@@ -1,3 +1,18 @@
+2021-10-13  Carlos Garcia Campos  <[email protected]>
+
+        HTTP method in web inspector network tab is not what WebKit actually sent after a redirect from POST to GET
+        https://bugs.webkit.org/show_bug.cgi?id=222558
+
+        Reviewed by Michael Catanzaro.
+
+        Test: http/tests/inspector/network/resource-redirect-request-headers.html
+
+        For redirects, use the previous request information combined with the new response information to create a
+        Redirect record.
+
+        * UserInterface/Models/Resource.js:
+        (WI.Resource.prototype.updateForRedirectResponse):
+
 2021-10-12  Alexey Proskuryakov  <[email protected]>
 
         Invoke build scripts with python3 explicitly

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js (284138 => 284139)


--- trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js	2021-10-14 00:41:04 UTC (rev 284138)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js	2021-10-14 00:49:17 UTC (rev 284139)
@@ -670,6 +670,7 @@
 
         let oldURL = this._url;
         let oldHeaders = this._requestHeaders;
+        let oldMethod = this._requestMethod;
 
         if (request.url)
             this._url = request.url;
@@ -676,7 +677,8 @@
 
         this._requestHeaders = request.headers || {};
         this._requestCookies = null;
-        this._redirects.push(new WI.Redirect(oldURL, request.method, oldHeaders, response.status, response.statusText, response.headers, elapsedTime));
+        this._requestMethod = request.method || null;
+        this._redirects.push(new WI.Redirect(oldURL, oldMethod, oldHeaders, response.status, response.statusText, response.headers, elapsedTime));
 
         if (oldURL !== request.url) {
             // Delete the URL components so the URL is re-parsed the next time it is requested.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to