2019-07-14 21:45:04 +02:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
2020-04-28 13:57:32 +02:00
|
|
|
const assert = require('assert');
|
2019-07-14 21:45:04 +02:00
|
|
|
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(() => {
|
2020-04-28 13:57:32 +02:00
|
|
|
assert.strictEqual(req.destroyed, true);
|
2019-07-14 21:45:04 +02:00
|
|
|
server.close();
|
|
|
|
keepAliveAgent.destroy();
|
|
|
|
}))
|
|
|
|
.on('data', common.mustCall());
|
|
|
|
}))
|
|
|
|
.end();
|
|
|
|
}));
|