fix: show request body for pending requests in Network tab - #10019
prathamswe wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
The request body was hidden until the response completed, so the Request tab and Copy as cURL omitted it for requests still awaiting a response. Gate it on the request having been sent instead, and never cache or show a body fetched while the request was still being sent.
5a19334 to
2044da8
Compare
There was a problem hiding this comment.
Code Review
This pull request ensures that the HTTP request body is displayed and copied correctly for pending or failed requests once it has been fully sent, preventing truncated bodies from being shown. It introduces tracking for whether data was fetched before the request completed sending and adds comprehensive unit tests. The feedback recommends replacing the placeholder PR link in the release notes and suggests applying the same gating logic to the encodedRequest getter to prevent other components from accessing truncated request bodies.
| * Fixed the Request tab and Copy as cURL missing the body of HTTP requests | ||
| that are still waiting for a response. A request body is only shown once it | ||
| has been fully sent, so it is never shown truncated. - | ||
| [#10019](https://github.com/flutter/devtools/pull/10019) |
| if (!_request.isRequestComplete || _fetchedBeforeRequestSent) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
[CONCERN] The encodedRequest getter (around line 398) also returns fullRequest.requestBody directly without checking _request.isRequestComplete or _fetchedBeforeRequestSent. To prevent other components (such as binary/hex viewers) from accessing a truncated or partial request body, consider applying the same gating logic to encodedRequest as well.
No open issue tracks this. Related: #9963 (Copy as cURL omitting headers/body on failed requests), #3042 (original Copy as cURL).
Summary
In the Network tab, the request body of an HTTP request is not shown, and Copy as cURL omits
--data-raw, while the request is still waiting for a response (e.g. a slowPOST). The body is only exposed once the response completes.Root cause: selecting a request already fetches its full data (
getHttpProfileRequest), including the request body, even while it is pending. ButDartIOHttpRequestData.requestBodyreturnsnulluntilisResponseComplete, which hides a body that DevTools already has. dart:io records the full request body and sets the requestendTimeas soon as the request has been sent, before any response arrives.Fix (
http_request_data.dart):requestBodyis gated onisRequestComplete(request fully sent, or failed) instead ofisResponseComplete. The body is now available for pending requests, in the Request tab and in Copy as cURL.Completed requests are unchanged. Requests that fail without a response now also expose their body.
Relation to #9963
#9963 is still open and touches the same line: it removes the
isResponseCompletecheck entirely, which also exposes the body for pending requests. This PR differs and adds:{"email":) for requests still being sent, and Copy as cURL then produces a broken command. This PR only exposes the body once the request is sent, including when the request was selected mid-upload.The two PRs are complementary: this PR does not include #9963's request-header or fetch-before-copy changes. #9963's tests pass on top of this change. Whichever lands first, I'm happy to rebase the other on top.
Tests
New tests in
test/http/curl_command_test.dart(constructed with plainDartIOHttpRequestData, not the test subclass that falls back to raw bytes):requestBodyand Copy as cURL (fails before this change).Existing tests for requests without a body and for headers are unchanged and pass.
Test plan
flutter test test/http/curl_command_test.dart test/screens/network/(154 passed)dart formatclean;flutter analyzereports no new issues (8 existing errors in unrelatedtest/test_infra/fixtures/apps)POSTin a running appPre-launch Checklist
General checklist
///).Issues checklist
contributions-welcomeorgood-first-issuelabel.contributions-welcomeorgood-first-issuelabel. I understand this means my PR might take longer to be reviewed.Tests checklist
AI-tooling checklist
Feature-change checklist
release-notes-not-requiredlabel or left a comment requesting the label be added.packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md.