diff --git a/test/parallel/test-http-missing-header-separator-cr.js b/test/parallel/test-http-missing-header-separator-cr.js index 15ef8195d19372..a1fa7a532f1606 100644 --- a/test/parallel/test-http-missing-header-separator-cr.js +++ b/test/parallel/test-http-missing-header-separator-cr.js @@ -26,7 +26,7 @@ server.listen(0, common.mustSucceed(() => { let response = ''; client.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; })); client.setEncoding('utf8'); diff --git a/test/parallel/test-http-server-close-all.js b/test/parallel/test-http-server-close-all.js index cf7d90b868162d..c4c211d97979a0 100644 --- a/test/parallel/test-http-server-close-all.js +++ b/test/parallel/test-http-server-close-all.js @@ -31,8 +31,10 @@ server.listen(0, function() { const client2 = connect(port); let response = ''; + client2.setEncoding('utf8'); + client2.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; if (response.endsWith('0\r\n\r\n')) { assert(response.startsWith('HTTP/1.1 200 OK\r\nConnection: keep-alive')); diff --git a/test/parallel/test-http-server-close-idle.js b/test/parallel/test-http-server-close-idle.js index 5218212996b159..361ccf990fabcc 100644 --- a/test/parallel/test-http-server-close-idle.js +++ b/test/parallel/test-http-server-close-idle.js @@ -33,8 +33,10 @@ server.listen(0, function() { const client2 = connect(port); let response = ''; + client2.setEncoding('utf8'); + client2.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; if (response.endsWith('0\r\n\r\n')) { assert(response.startsWith('HTTP/1.1 200 OK\r\nConnection: keep-alive')); diff --git a/test/parallel/test-http-server-headers-timeout-delayed-headers.js b/test/parallel/test-http-server-headers-timeout-delayed-headers.js index dc0efc5855ad02..af4a5df4b7f530 100644 --- a/test/parallel/test-http-server-headers-timeout-delayed-headers.js +++ b/test/parallel/test-http-server-headers-timeout-delayed-headers.js @@ -33,8 +33,9 @@ server.listen(0, common.mustCall(() => { const client = connect(server.address().port); let response = ''; + client.setEncoding('utf8'); client.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; })); const errOrEnd = common.mustSucceed(function(err) { diff --git a/test/parallel/test-http-server-headers-timeout-interrupted-headers.js b/test/parallel/test-http-server-headers-timeout-interrupted-headers.js index ce38123c15b684..9d25940ec65cd1 100644 --- a/test/parallel/test-http-server-headers-timeout-interrupted-headers.js +++ b/test/parallel/test-http-server-headers-timeout-interrupted-headers.js @@ -33,8 +33,9 @@ server.listen(0, common.mustCall(() => { const client = connect(server.address().port); let response = ''; + client.setEncoding('utf8'); client.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; })); const errOrEnd = common.mustSucceed(function(err) { diff --git a/test/parallel/test-http-server-headers-timeout-keepalive.js b/test/parallel/test-http-server-headers-timeout-keepalive.js index ba82cb0e0c9cb1..1affc5a4befff4 100644 --- a/test/parallel/test-http-server-headers-timeout-keepalive.js +++ b/test/parallel/test-http-server-headers-timeout-keepalive.js @@ -47,8 +47,9 @@ server.listen(0, common.mustCall(() => { let second = false; let response = ''; + client.setEncoding('utf8'); client.on('data', common.mustCallAtLeast((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; // First response has ended if (!second && response.endsWith('\r\n\r\n')) { diff --git a/test/parallel/test-http-server-headers-timeout-pipelining.js b/test/parallel/test-http-server-headers-timeout-pipelining.js index 658bdf9a3aaf1c..bfd5af6bcefc1f 100644 --- a/test/parallel/test-http-server-headers-timeout-pipelining.js +++ b/test/parallel/test-http-server-headers-timeout-pipelining.js @@ -33,8 +33,9 @@ server.listen(0, common.mustCall(() => { let second = false; let response = ''; + client.setEncoding('utf8'); client.on('data', common.mustCallAtLeast((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; // First response has ended if (!second && response.endsWith('\r\n\r\n')) { diff --git a/test/parallel/test-http-server-request-timeout-delayed-body.js b/test/parallel/test-http-server-request-timeout-delayed-body.js index 91cb5a851bcfe3..ac2120ef393719 100644 --- a/test/parallel/test-http-server-request-timeout-delayed-body.js +++ b/test/parallel/test-http-server-request-timeout-delayed-body.js @@ -40,8 +40,9 @@ server.listen(0, common.mustCall(() => { const client = connect(server.address().port); let response = ''; + client.setEncoding('utf8'); client.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; })); client.resume(); diff --git a/test/parallel/test-http-server-request-timeout-delayed-headers.js b/test/parallel/test-http-server-request-timeout-delayed-headers.js index ae4260ddeefa18..304a78b96a77d3 100644 --- a/test/parallel/test-http-server-request-timeout-delayed-headers.js +++ b/test/parallel/test-http-server-request-timeout-delayed-headers.js @@ -28,8 +28,9 @@ server.listen(0, common.mustCall(() => { const client = connect(server.address().port); let response = ''; + client.setEncoding('utf8'); client.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; })); const errOrEnd = common.mustSucceed(function(err) { diff --git a/test/parallel/test-http-server-request-timeout-interrupted-body.js b/test/parallel/test-http-server-request-timeout-interrupted-body.js index 3b147693d97550..aa4843a48373df 100644 --- a/test/parallel/test-http-server-request-timeout-interrupted-body.js +++ b/test/parallel/test-http-server-request-timeout-interrupted-body.js @@ -40,8 +40,9 @@ server.listen(0, common.mustCall(() => { const client = connect(server.address().port); let response = ''; + client.setEncoding('utf8'); client.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; })); const errOrEnd = common.mustSucceed(function(err) { diff --git a/test/parallel/test-http-server-request-timeout-interrupted-headers.js b/test/parallel/test-http-server-request-timeout-interrupted-headers.js index 45c773996be209..eb9914dad1f56a 100644 --- a/test/parallel/test-http-server-request-timeout-interrupted-headers.js +++ b/test/parallel/test-http-server-request-timeout-interrupted-headers.js @@ -28,8 +28,9 @@ server.listen(0, common.mustCall(() => { const client = connect(server.address().port); let response = ''; + client.setEncoding('utf8'); client.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; })); const errOrEnd = common.mustSucceed(function(err) { diff --git a/test/parallel/test-http-server-request-timeout-keepalive.js b/test/parallel/test-http-server-request-timeout-keepalive.js index fd460b86bd1ca9..215d3dbc086ccb 100644 --- a/test/parallel/test-http-server-request-timeout-keepalive.js +++ b/test/parallel/test-http-server-request-timeout-keepalive.js @@ -45,8 +45,9 @@ server.listen(0, common.mustCall(() => { let second = false; let response = ''; + client.setEncoding('utf8'); client.on('data', common.mustCallAtLeast((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; // First response has ended if (!second && response.endsWith('\r\n\r\n')) { diff --git a/test/parallel/test-http-server-request-timeout-pipelining.js b/test/parallel/test-http-server-request-timeout-pipelining.js index 2647268b11fc87..e00840791a3773 100644 --- a/test/parallel/test-http-server-request-timeout-pipelining.js +++ b/test/parallel/test-http-server-request-timeout-pipelining.js @@ -27,8 +27,9 @@ server.listen(0, common.mustCall(() => { let second = false; let response = ''; + client.setEncoding('utf8'); client.on('data', common.mustCallAtLeast((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; // First response has ended if (!second && response.endsWith('\r\n\r\n')) { diff --git a/test/parallel/test-http-server-request-timeout-upgrade.js b/test/parallel/test-http-server-request-timeout-upgrade.js index 0d95a8b22c2b04..ad4fbe5c5e9a03 100644 --- a/test/parallel/test-http-server-request-timeout-upgrade.js +++ b/test/parallel/test-http-server-request-timeout-upgrade.js @@ -33,8 +33,9 @@ server.listen(0, common.mustCall(() => { const client = connect(server.address().port); let response = ''; + client.setEncoding('utf8'); client.on('data', common.mustCallAtLeast((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; }, 1)); client.on('end', common.mustCall(() => { diff --git a/test/parallel/test-http-server-request-timeouts-mixed.js b/test/parallel/test-http-server-request-timeouts-mixed.js index 44c8d03e3c17ae..41b7542c1bdbed 100644 --- a/test/parallel/test-http-server-request-timeouts-mixed.js +++ b/test/parallel/test-http-server-request-timeouts-mixed.js @@ -43,8 +43,9 @@ function createClient(server) { completed: false }; + request.client.setEncoding('utf8'); request.client.on('data', common.mustCallAtLeast((chunk) => { - request.response += chunk.toString('utf-8'); + request.response += chunk; })); request.client.on('end', common.mustCall(() => { diff --git a/test/parallel/test-http-transfer-encoding-repeated-chunked.js b/test/parallel/test-http-transfer-encoding-repeated-chunked.js index f38c625646c078..a5680af9586b79 100644 --- a/test/parallel/test-http-transfer-encoding-repeated-chunked.js +++ b/test/parallel/test-http-transfer-encoding-repeated-chunked.js @@ -34,7 +34,7 @@ server.listen(0, common.mustSucceed(() => { let response = ''; client.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; })); client.setEncoding('utf8'); diff --git a/test/parallel/test-http-transfer-encoding-smuggling.js b/test/parallel/test-http-transfer-encoding-smuggling.js index 9cd611464fec08..50c44ca5fc62ab 100644 --- a/test/parallel/test-http-transfer-encoding-smuggling.js +++ b/test/parallel/test-http-transfer-encoding-smuggling.js @@ -35,7 +35,7 @@ server.listen(0, common.mustSucceed(() => { // Verify that the server listener is never called client.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; })); client.setEncoding('utf8'); diff --git a/test/parallel/test-https-server-close-all.js b/test/parallel/test-https-server-close-all.js index c388260db3b484..1c9092ff5c9237 100644 --- a/test/parallel/test-https-server-close-all.js +++ b/test/parallel/test-https-server-close-all.js @@ -42,8 +42,9 @@ server.listen(0, function() { const client2 = connect({ port, rejectUnauthorized: false }); let response = ''; + client2.setEncoding('utf8'); client2.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; if (response.endsWith('0\r\n\r\n')) { assert(response.startsWith('HTTP/1.1 200 OK\r\nConnection: keep-alive')); diff --git a/test/parallel/test-https-server-close-idle.js b/test/parallel/test-https-server-close-idle.js index eb5a8c3585bb96..7f093c47cd8609 100644 --- a/test/parallel/test-https-server-close-idle.js +++ b/test/parallel/test-https-server-close-idle.js @@ -44,8 +44,9 @@ server.listen(0, function() { const client2 = connect({ port, rejectUnauthorized: false }); let response = ''; + client2.setEncoding('utf8'); client2.on('data', common.mustCall((chunk) => { - response += chunk.toString('utf-8'); + response += chunk; if (response.endsWith('0\r\n\r\n')) { assert(response.startsWith('HTTP/1.1 200 OK\r\nConnection: keep-alive'));