mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 13:23:28 +00:00

Remove code to skip Windows in test-http-server-keepalive-req-gc. The test now works reliably on Windows (I think). PR-URL: https://github.com/nodejs/node/pull/29354 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
41 lines
996 B
JavaScript
41 lines
996 B
JavaScript
// Flags: --expose-gc
|
|
'use strict';
|
|
const common = require('../common');
|
|
const onGC = require('../common/ongc');
|
|
const { createServer } = require('http');
|
|
const { connect } = require('net');
|
|
|
|
// Make sure that for HTTP keepalive requests, the req object can be
|
|
// garbage collected once the request is finished.
|
|
// Refs: https://github.com/nodejs/node/issues/9668
|
|
|
|
let client;
|
|
const server = createServer(common.mustCall((req, res) => {
|
|
onGC(req, { ongc: common.mustCall(() => { server.close(); }) });
|
|
req.resume();
|
|
req.on('end', common.mustCall(() => {
|
|
setImmediate(() => {
|
|
client.end();
|
|
global.gc();
|
|
});
|
|
}));
|
|
res.end('hello world');
|
|
}));
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
client = connect(server.address().port);
|
|
|
|
const req = [
|
|
'POST / HTTP/1.1',
|
|
`Host: localhost:${server.address().port}`,
|
|
'Connection: keep-alive',
|
|
'Content-Length: 11',
|
|
'',
|
|
'hello world',
|
|
''
|
|
].join('\r\n');
|
|
|
|
client.write(req);
|
|
client.unref();
|
|
}));
|