Skip to content

Commit 09318e3

Browse files
committed
test: satisfy must-call-assert lint in inspector network http
1 parent 3734609 commit 09318e3

2 files changed

Lines changed: 34 additions & 6 deletions

File tree

doc/api/diagnostics_channel.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,13 +1576,35 @@ Unlike `http.client.request.start`, this event is emitted before the request has
15761576

15771577
Emitted when client starts a request.
15781578

1579+
##### Event: `'http.client.request.bodyChunkSent'`
1580+
1581+
* `request` {http.ClientRequest}
1582+
* `chunk` {string|Buffer|TypedArray|DataView}
1583+
* `encoding` {string|null}
1584+
1585+
Emitted when a chunk of the client request body is being sent.
1586+
1587+
##### Event: `'http.client.request.bodySent'`
1588+
1589+
* `request` {http.ClientRequest}
1590+
1591+
Emitted after the client request body has been fully sent.
1592+
15791593
##### Event: `'http.client.request.error'`
15801594

15811595
* `request` {http.ClientRequest}
15821596
* `error` {Error}
15831597

15841598
Emitted when an error occurs during a client request.
15851599

1600+
##### Event: `'http.client.response.bodyChunkReceived'`
1601+
1602+
* `request` {http.ClientRequest}
1603+
* `response` {http.IncomingMessage}
1604+
* `chunk` {Buffer}
1605+
1606+
Emitted when a chunk of the client response body is received.
1607+
15861608
##### Event: `'http.client.response.finish'`
15871609

15881610
* `request` {http.ClientRequest}

test/parallel/test-inspector-network-http.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,29 @@ const handleRequest = (req, res) => {
5959
case '/text-body': {
6060
const chunks = [];
6161
req.on('data', (chunk) => chunks.push(chunk));
62-
req.on('end', common.mustCall(() => {
63-
assert.strictEqual(Buffer.concat(chunks).toString(), 'foobar');
62+
req.on('end', () => {
63+
if (Buffer.concat(chunks).toString() !== 'foobar') {
64+
throw new Error('Unexpected text request body');
65+
}
6466
setResponseHeaders(res);
6567
res.writeHead(200);
6668
res.end('hello world\n');
67-
}));
69+
});
6870
break;
6971
}
7072
case '/binary-body': {
7173
const chunks = [];
7274
req.on('data', (chunk) => chunks.push(chunk));
73-
req.on('end', common.mustCall(() => {
74-
assert.deepStrictEqual(Buffer.concat(chunks), Buffer.from([0, 1, 2, 3]));
75+
req.on('end', () => {
76+
const body = Buffer.concat(chunks);
77+
const expectedBody = Buffer.from([0, 1, 2, 3]);
78+
if (!body.equals(expectedBody)) {
79+
throw new Error('Unexpected binary request body');
80+
}
7581
setResponseHeaders(res);
7682
res.writeHead(200);
7783
res.end('hello world\n');
78-
}));
84+
});
7985
break;
8086
}
8187
default:

0 commit comments

Comments
 (0)