diff --git a/doc/api/diagnostics_channel.md b/doc/api/diagnostics_channel.md index 038c7cb29dd2d1..246cd2ffa29dc5 100644 --- a/doc/api/diagnostics_channel.md +++ b/doc/api/diagnostics_channel.md @@ -1576,6 +1576,20 @@ Unlike `http.client.request.start`, this event is emitted before the request has Emitted when client starts a request. +##### Event: `'http.client.request.bodyChunkSent'` + +* `request` {http.ClientRequest} +* `chunk` {string|Buffer|TypedArray|DataView} +* `encoding` {string|null} + +Emitted when a chunk of the client request body is being sent. + +##### Event: `'http.client.request.bodySent'` + +* `request` {http.ClientRequest} + +Emitted after the client request body has been fully sent. + ##### Event: `'http.client.request.error'` * `request` {http.ClientRequest} @@ -1583,6 +1597,14 @@ Emitted when client starts a request. Emitted when an error occurs during a client request. +##### Event: `'http.client.response.bodyChunkReceived'` + +* `request` {http.ClientRequest} +* `response` {http.IncomingMessage} +* `chunk` {Buffer} + +Emitted when a chunk of the client response body is received. + ##### Event: `'http.client.response.finish'` * `request` {http.ClientRequest} diff --git a/test/parallel/test-inspector-network-http.js b/test/parallel/test-inspector-network-http.js index 340e6e5feb9e37..d5190c3b37bf32 100644 --- a/test/parallel/test-inspector-network-http.js +++ b/test/parallel/test-inspector-network-http.js @@ -59,23 +59,29 @@ const handleRequest = (req, res) => { case '/text-body': { const chunks = []; req.on('data', (chunk) => chunks.push(chunk)); - req.on('end', common.mustCall(() => { - assert.strictEqual(Buffer.concat(chunks).toString(), 'foobar'); + req.on('end', () => { + if (Buffer.concat(chunks).toString() !== 'foobar') { + throw new Error('Unexpected text request body'); + } setResponseHeaders(res); res.writeHead(200); res.end('hello world\n'); - })); + }); break; } case '/binary-body': { const chunks = []; req.on('data', (chunk) => chunks.push(chunk)); - req.on('end', common.mustCall(() => { - assert.deepStrictEqual(Buffer.concat(chunks), Buffer.from([0, 1, 2, 3])); + req.on('end', () => { + const body = Buffer.concat(chunks); + const expectedBody = Buffer.from([0, 1, 2, 3]); + if (!body.equals(expectedBody)) { + throw new Error('Unexpected binary request body'); + } setResponseHeaders(res); res.writeHead(200); res.end('hello world\n'); - })); + }); break; } default: