Skip to content

fix(network): make main-document POST bodies available to getRequestPostData - #230

Open
BibekPathak wants to merge 1 commit into
lexmount:mainfrom
BibekPathak:main
Open

fix(network): make main-document POST bodies available to getRequestPostData#230
BibekPathak wants to merge 1 commit into
lexmount:mainfrom
BibekPathak:main

Conversation

@BibekPathak

Copy link
Copy Markdown
Contributor

Network.getRequestPostData returned "No post data available" for form-POST
navigations even though Network.requestWillBeSent carried the postData.
The captured-request-body store had a single writer, record_subresource_request_body
(backlog.rs), so only subresource requests were recorded; the main-document
navigation path recorded response bodies but never request bodies.

Record the main-document navigation request body alongside the response body
in start_observed_main_document_navigation_progress_background_events, mirroring
the subresource path: store it in both the collector store (so BiDi
network.getData also works) and the runtime slot's captured-request store
(what getRequestPostData reads). No addDataCollector setup is required to read
it back, matching Chromium's semantics.

Add regression coverage: a focused test driving the main-document progress path
with a POST body, and an end-to-end test submitting a real


and asserting getRequestPostData returns the urlencoded body.

@BibekPathak

Copy link
Copy Markdown
Contributor Author

@ldm0 please have look at this!!

@ldm0
ldm0 self-requested a review August 26, 2026 17:31

@ldm0 ldm0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for tweaking this, a few observations:

) -> MainDocumentBodyProgressSource {
let session_ids = main_document_network_event_session_ids(conn, state.session_id.as_deref());
record_pending_main_document_response_body(conn, state, &session_ids);
record_main_document_request_body(conn, state, &session_ids);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

record_main_document_request_body only runs from start_observed_main_document_navigation_progress_background_events, but request-stage Fetch navigations return through the Fetch pause path without entering this function. After Fetch.continueRequest, the navigation is resumed through the normal loader without another request-body capture point.

This means Network.getRequestPostData still has no captured body for main-document POST requests when Fetch interception is enabled, including bodies overridden via Fetch.continueRequest.

Pelease move this capture into a path shared by both normal and Fetch-intercepted main-document requests, or explicitly capture it in the Fetch branch as well.

let Some(request_id) = state.request_id.clone() else {
return;
};
let Some(request_body) = state.clone_request_body_bytes() else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

clone_request_body_bytes() intentionally prefers request_body_bytes, which may contain binary file payloads for multipart forms. NavigationDispatchState::request_body, on the other hand, is documented as the text projection used by CDP request events and Fetch interception.

CDP Network.getRequestPostData requires multipart file contents to be omitted, but storing the raw transport bytes in the runtime captured-request store means a main-document file upload can return the actual file bytes (or their base64 representation).

Please keep request_body_bytes for the BiDi collector, while storing request_body in the CDP captured-request store. It would also be good to add a multipart file-upload regression test for this distinction.

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