test: add request body lifecycle tests for Copy as cURL - #10020
prathamgoyal787 wants to merge 3 commits into
Conversation
2044da8 to
d6b9d53
Compare
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.
d6b9d53 to
45c842e
Compare
There was a problem hiding this comment.
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.
|
Thanks for the heads up on #9963 ! I just landed that. |
Merge master, which already contains the request body fix from flutter#9963, and keep only the tests from this PR as regression coverage.
|
Since #9963 landed the same fix to As this no longer changes DevTools behavior, could a maintainer please add the |
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.requestBodyso the body was shown for pending requests. #9963 has since landed an equivalent fix inhttp_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 lifecyclegroup intest/http/curl_command_test.dart. The tests construct plainDartIOHttpRequestData, not the test subclass that falls back to raw bytes, so they exercise the realrequestBodygetter:requestBodyand Copy as cURL.getFullRequestDatawhile the request is pending survives themergecalls from profile polling and the response completing.Test plan
flutter test test/http/curl_command_test.dart(18 passed)dart formatclean;flutter analyzereports no issues in the test filePre-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.