0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-http-client-agent-abort-close-event.js
Robert Nagy d247a8e1dc http: emit close on socket re-use
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>
2019-10-15 16:51:09 -07:00

24 lines
542 B
JavaScript

'use strict';
const common = require('../common');
const http = require('http');
const server = http.createServer(common.mustNotCall());
const keepAliveAgent = new http.Agent({ keepAlive: true });
server.listen(0, common.mustCall(() => {
const req = http.get({
port: server.address().port,
agent: keepAliveAgent
});
req
.on('socket', common.mustNotCall())
.on('response', common.mustNotCall())
.on('close', common.mustCall(() => {
server.close();
keepAliveAgent.destroy();
}))
.abort();
}));