mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
b04e88439a
Calling destroy() on a completed ClientRequest, i.e. once 'close' will be emitted should be a noop. Also before emitting 'close' destroyed === true. Fixes: https://github.com/nodejs/node/issues/32851 PR-URL: https://github.com/nodejs/node/pull/33120 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
26 lines
623 B
JavaScript
26 lines
623 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
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(() => {
|
|
assert.strictEqual(req.destroyed, true);
|
|
server.close();
|
|
keepAliveAgent.destroy();
|
|
}))
|
|
.abort();
|
|
}));
|