mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
PR-URL: https://github.com/nodejs/node/pull/60729 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
37 lines
992 B
JavaScript
37 lines
992 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const http = require('http');
|
|
|
|
for (const method of ['abort', 'destroy']) {
|
|
const server = http.createServer(common.mustCall((req, res) => {
|
|
res.end(req.url);
|
|
}));
|
|
server.listen(0, common.mustCall(() => {
|
|
const agent = http.Agent({ keepAlive: true });
|
|
|
|
const req = http
|
|
.request({
|
|
port: server.address().port,
|
|
agent
|
|
})
|
|
.on('socket', common.mustCall((socket) => {
|
|
socket.on('free', common.mustCall());
|
|
}))
|
|
.on('response', common.mustCall((res) => {
|
|
assert.strictEqual(req.destroyed, false);
|
|
res.on('end', common.mustCall(() => {
|
|
assert.strictEqual(req.destroyed, true);
|
|
req[method]();
|
|
assert.strictEqual(req.socket.destroyed, false);
|
|
agent.destroy();
|
|
server.close();
|
|
})).resume();
|
|
}))
|
|
.end();
|
|
assert.strictEqual(req.destroyed, false);
|
|
}));
|
|
}
|