mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 08:42:45 +00:00

PR-URL: https://github.com/nodejs/node/pull/28685 Refs: https://github.com/nodejs/node/issues/28684 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
28 lines
613 B
JavaScript
28 lines
613 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
|
|
const server = http.createServer(common.mustCall((req, res) => {
|
|
res.end('hello');
|
|
}));
|
|
|
|
const keepAliveAgent = new http.Agent({ keepAlive: true });
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
const req = http.get({
|
|
port: server.address().port,
|
|
agent: keepAliveAgent
|
|
});
|
|
|
|
req
|
|
.on('response', common.mustCall((res) => {
|
|
res
|
|
.on('close', common.mustCall(() => {
|
|
server.close();
|
|
keepAliveAgent.destroy();
|
|
}))
|
|
.on('data', common.mustCall());
|
|
}))
|
|
.end();
|
|
}));
|