MCPcopy Index your code
hub / github.com/nodejs/node / onClientStreamBodyChunkSent

Function onClientStreamBodyChunkSent

lib/internal/inspector/network_http2.js:138–171  ·  view source on GitHub ↗

* When a chunk of the request body is being sent, cache it until `getRequestPostData` request. * https://chromedevtools.github.io/devtools-protocol/1-3/Network/#method-getRequestPostData * @param {{ * stream: import('http2').ClientHttp2Stream, * writev: boolean, * data: Buffer | string |

({ stream, writev, data, encoding })

Source from the content-addressed store, hash-verified

136 * }} event
137 */
138function onClientStreamBodyChunkSent({ stream, writev, data, encoding }) {
139 if (typeof stream[kInspectorRequestId] !== 'string') {
140 return;
141 }
142
143 let chunk;
144
145 if (writev) {
146 if (data.allBuffers) {
147 chunk = Buffer.concat(data);
148 } else {
149 const buffers = [];
150 for (let i = 0; i < data.length; ++i) {
151 if (typeof data[i].chunk === 'string') {
152 buffers.push(Buffer.from(data[i].chunk, data[i].encoding));
153 } else {
154 buffers.push(data[i].chunk);
155 }
156 }
157 chunk = Buffer.concat(buffers);
158 }
159 } else if (typeof data === 'string') {
160 chunk = Buffer.from(data, encoding);
161 } else {
162 chunk = data;
163 }
164
165 Network.dataSent({
166 requestId: stream[kInspectorRequestId],
167 timestamp: getMonotonicTime(),
168 dataLength: chunk.byteLength,
169 data: chunk,
170 });
171}
172
173/**
174 * Mark a request body as fully sent.

Callers

nothing calls this directly

Calls 4

getMonotonicTimeFunction · 0.85
concatMethod · 0.80
pushMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…