Files
node/test/parallel/test-http-req-close-robust-from-tampering.js
Phillip Markert 86c871eced test: replace forEach() with for...of in parallel tests
Replace `Array.prototype.forEach()` with `for...of` loops across 17
tests in `test/parallel`, so each loop body reads as a plain statement
rather than an arrow callback.

None of the iterated values are sparse arrays, the one case where
`forEach` and `for...of` genuinely differ, so both constructs visit the
same elements in the same order. No callback relied on `this`, an early
return, or async behaviour, and the number of assertions run in each
file is unchanged.

Signed-off-by: Phillip Markert <phillip@ephisys.com>
PR-URL: https://github.com/nodejs/node/pull/65272
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
2026-08-15 21:59:44 +00:00

29 lines
665 B
JavaScript

'use strict';
const common = require('../common');
const { createServer } = require('http');
const { connect } = require('net');
// Make sure that calling the semi-private close() handlers manually doesn't
// cause an error.
const server = createServer(common.mustCall((req, res) => {
const closeHandlers = req.client._events.close;
for (const fn of closeHandlers) { fn.bind(req)(); }
}));
server.unref();
server.listen(0, common.mustCall(() => {
const client = connect(server.address().port);
const req = [
'POST / HTTP/1.1',
'Host: example.com',
'Content-Length: 11',
'',
'hello world',
].join('\r\n');
client.end(req);
}));