From 5b2f8a5a3a1eed742b4bbb430fde429d29b76e8c Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Wed, 5 Mar 2025 10:20:03 +0000 Subject: [PATCH] inspector: add protocol methods retrieving sent/received data Add protocol method `Network.dataSent` to buffer request data. And expose protocol methods `Network.getRequestPostData` and `Network.getResponseBody` allowing devtool to retrieve buffered data. --- doc/api/inspector.md | 14 ++ lib/inspector.js | 1 + lib/internal/inspector/network.js | 21 ++ lib/internal/inspector/network_http.js | 34 ++-- lib/internal/inspector/network_undici.js | 37 ++-- src/inspector/network_agent.cc | 189 +++++++++++++++--- src/inspector/network_agent.h | 33 ++- src/inspector/node_protocol.pdl | 21 ++ .../test-inspector-emit-protocol-event.js | 7 +- .../test-inspector-network-data-received.js | 72 +++++-- .../test-inspector-network-data-sent.js | 136 +++++++++++++ 11 files changed, 480 insertions(+), 85 deletions(-) create mode 100644 test/parallel/test-inspector-network-data-sent.js diff --git a/doc/api/inspector.md b/doc/api/inspector.md index a056065f95820d..04c09f94cb7f65 100644 --- a/doc/api/inspector.md +++ b/doc/api/inspector.md @@ -524,6 +524,20 @@ This feature is only available with the `--experimental-network-inspection` flag Broadcasts the `Network.dataReceived` event to connected frontends, or buffers the data if `Network.streamResourceContent` command was not invoked for the given request yet. +Also enables `Network.getResponseBody` command to retrieve the response data. + +### `inspector.Network.dataSent([params])` + + + +* `params` {Object} + +This feature is only available with the `--experimental-network-inspection` flag enabled. + +Enables `Network.getRequestPostData` command to retrieve the request data. + ### `inspector.Network.requestWillBeSent([params])`