Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions doc/api/diagnostics_channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -1576,13 +1576,35 @@ 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}
* `error` {Error}

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}
Expand Down
18 changes: 12 additions & 6 deletions test/parallel/test-inspector-network-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading