Skip to content

test: add request body lifecycle tests for Copy as cURL - #10020

Open
prathamgoyal787 wants to merge 3 commits into
flutter:masterfrom
prathamgoyal787:fix/network-pending-request-body
Open

prathamgoyal787 wants to merge 3 commits into
flutter:masterfrom
prathamgoyal787:fix/network-pending-request-body

Conversation

@prathamgoyal787

@prathamgoyal787 prathamgoyal787 commented Sep 23, 2026 •

Copy link
Copy Markdown

Related: #9963 (Copy as cURL omitting headers/body on failed requests).

Summary

This PR adds regression tests for the HTTP request body across the lifecycle of a request in the Network tab. It makes no source changes.

It originally also changed DartIOHttpRequestData.requestBody so the body was shown for pending requests. #9963 has since landed an equivalent fix in http_request_data.dart, so I merged master and dropped my source changes and release note. What remains are the tests, which cover behavior that #9963 does not test directly.

Tests

New NetworkCurlCommand request body lifecycle group in test/http/curl_command_test.dart. The tests construct plain DartIOHttpRequestData, not the test subclass that falls back to raw bytes, so they exercise the real requestBody getter:

  • A pending request awaiting its response includes the body in requestBody and Copy as cURL.
  • A completed request includes the body.
  • A request that failed without a response includes the body.
  • With the fake VM service, the body fetched by getFullRequestData while the request is pending survives the merge calls from profile polling and the response completing.

Test plan

  • flutter test test/http/curl_command_test.dart (18 passed)
  • dart format clean; flutter analyze reports no issues in the test file

Pre-launch Checklist

General checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read the Flutter Style Guide recently, and have followed its advice.
  • I signed the CLA.
  • I updated/added relevant documentation (comments explaining the new tests).

Issues checklist

Tests checklist

  • I added new tests to check the change I am making...
  • OR there is a reason for not adding tests, which I explained in the PR description.

AI-tooling checklist

  • I did not use any AI tooling in creating this PR.
  • OR I did use AI tooling, and...
    • I read the AI contributions guidelines and agree to follow them.
    • I reviewed all AI-generated code before opening this PR.
    • I understand and am able to discuss the code in this PR.
    • I have verifed the accuracy of any AI-generated text included in the PR description.
    • I commit to verifying the accuracy of any AI-generated code or text that I upload in response to review comments.

Feature-change checklist

  • This PR does not change the DevTools UI or behavior and...
    • I added the release-notes-not-required label or left a comment requesting the label be added.
  • OR this PR does change the DevTools UI or behavior and...
    • I added an entry to packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md.
    • I included before/after screenshots and/or a GIF demo of the new UI to my PR description.
    • I ran the DevTools app locally to manually verify my changes.

build.yaml badge

@prathamgoyal787
prathamgoyal787 requested a review from a team as a code owner September 23, 2026 08:30
@prathamgoyal787
prathamgoyal787 requested review from srawlins and removed request for a team September 23, 2026 08:30
prathamgoyal787 added a commit to prathamgoyal787/devtools that referenced this pull request Sep 23, 2026
@prathamgoyal787
prathamgoyal787 force-pushed the fix/network-pending-request-body branch from 2044da8 to d6b9d53 Compare September 23, 2026 08:30
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.
@prathamgoyal787
prathamgoyal787 force-pushed the fix/network-pending-request-body branch from d6b9d53 to 45c842e Compare September 23, 2026 08:31

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves the handling of HTTP request bodies in the DevTools Network tab. It introduces a mechanism to track whether a request body was fetched before the request was fully sent, preventing the display of truncated or partial bodies. The changes ensure that request bodies are only shown once they are fully available, improving the reliability of the Request tab and Copy as cURL functionality. Comprehensive tests have been added to verify the request body lifecycle under various conditions, including pending, completed, and failed requests. I have no feedback to provide as there were no review comments.

@srawlins

Copy link
Copy Markdown
Contributor

Thanks for the heads up on #9963 ! I just landed that.

@srawlins srawlins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love those tests!

Merge master, which already contains the request body fix from flutter#9963,
and keep only the tests from this PR as regression coverage.
@prathamgoyal787 prathamgoyal787 changed the title fix: show request body for pending requests in Network tab test: add request body lifecycle tests for Copy as cURL Sep 26, 2026
@prathamgoyal787

Copy link
Copy Markdown
Author

Since #9963 landed the same fix to http_request_data.dart, I've merged master and dropped my source changes, so this PR now only adds the request body lifecycle tests (pending, completed, failed, and retained across profile refreshes) as regression coverage. I've updated the title and description to match.

As this no longer changes DevTools behavior, could a maintainer please add the release-notes-not-required label?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants