* 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 })
| 136 | * }} event |
| 137 | */ |
| 138 | function 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. |
nothing calls this directly
no test coverage detected
searching dependent graphs…