* When response headers are received, emit Network.responseReceived event. * https://chromedevtools.github.io/devtools-protocol/1-3/Network/#event-responseReceived * @param {{ stream: import('http2').ClientHttp2Stream, headers: object }} event
({ stream, headers })
| 191 | * @param {{ stream: import('http2').ClientHttp2Stream, headers: object }} event |
| 192 | */ |
| 193 | function onClientStreamFinish({ stream, headers }) { |
| 194 | if (typeof stream[kInspectorRequestId] !== 'string') { |
| 195 | return; |
| 196 | } |
| 197 | |
| 198 | const { 0: convertedHeaderObject, 3: statusCode, 4: charset, 5: mimeType } = convertHeaderObject(headers); |
| 199 | |
| 200 | Network.responseReceived({ |
| 201 | requestId: stream[kInspectorRequestId], |
| 202 | timestamp: getMonotonicTime(), |
| 203 | type: kResourceType.Other, |
| 204 | response: { |
| 205 | url: stream[kRequestUrl], |
| 206 | status: statusCode, |
| 207 | statusText: '', |
| 208 | headers: convertedHeaderObject, |
| 209 | mimeType, |
| 210 | charset, |
| 211 | }, |
| 212 | }); |
| 213 | |
| 214 | // Unlike stream.on('data', ...), this does not put the stream into flowing mode. |
| 215 | EventEmitter.prototype.on.call(stream, 'data', (chunk) => { |
| 216 | /** |
| 217 | * When a chunk of the response body has been received, cache it until `getResponseBody` request |
| 218 | * https://chromedevtools.github.io/devtools-protocol/1-3/Network/#method-getResponseBody or |
| 219 | * stream it with `streamResourceContent` request. |
| 220 | * https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-streamResourceContent |
| 221 | */ |
| 222 | |
| 223 | Network.dataReceived({ |
| 224 | requestId: stream[kInspectorRequestId], |
| 225 | timestamp: getMonotonicTime(), |
| 226 | dataLength: chunk.byteLength, |
| 227 | encodedDataLength: chunk.byteLength, |
| 228 | data: chunk, |
| 229 | }); |
| 230 | }); |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * When user code completes consuming the response body, emit Network.loadingFinished event. |
nothing calls this directly
no test coverage detected