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

Function onClientResponseFinish

lib/internal/inspector/network_http.js:118–157  ·  view source on GitHub ↗

* When response headers are received, emit Network.responseReceived event. * https://chromedevtools.github.io/devtools-protocol/1-3/Network/#event-responseReceived * @param {{ request: import('http').ClientRequest, error: any }} event

({ request, response })

Source from the content-addressed store, hash-verified

116 * @param {{ request: import('http').ClientRequest, error: any }} event
117 */
118function onClientResponseFinish({ request, response }) {
119 if (typeof request[kInspectorRequestId] !== 'string') {
120 return;
121 }
122
123 const { 0: headers, 2: charset, 3: mimeType } = convertHeaderObject(response.headers);
124
125 Network.responseReceived({
126 requestId: request[kInspectorRequestId],
127 timestamp: getMonotonicTime(),
128 type: kResourceType.Other,
129 response: {
130 url: request[kRequestUrl],
131 status: response.statusCode,
132 statusText: response.statusMessage ?? '',
133 headers,
134 mimeType,
135 charset,
136 },
137 });
138
139 // Unlike response.on('data', ...), this does not put the stream into flowing mode.
140 EventEmitter.prototype.on.call(response, 'data', (chunk) => {
141 Network.dataReceived({
142 requestId: request[kInspectorRequestId],
143 timestamp: getMonotonicTime(),
144 dataLength: chunk.byteLength,
145 encodedDataLength: chunk.byteLength,
146 data: chunk,
147 });
148 });
149
150 // Wait until the response body is consumed by user code.
151 response.once('end', () => {
152 Network.loadingFinished({
153 requestId: request[kInspectorRequestId],
154 timestamp: getMonotonicTime(),
155 });
156 });
157}
158
159module.exports = registerDiagnosticChannels([
160 ['http.client.request.created', onClientRequestCreated],

Callers

nothing calls this directly

Calls 4

getMonotonicTimeFunction · 0.85
convertHeaderObjectFunction · 0.70
callMethod · 0.45
onceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…