`request.abort()` did not destroy the socket if it was called before a socket was assigned to the request and the request did not use an `Agent` or a Unix Domain Socket was used. Fixes: https://github.com/nodejs/node/issues/10812 PR-URL: https://github.com/nodejs/node/pull/10818 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
25 lines
519 B
JavaScript
25 lines
519 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
|
|
const server = http.createServer(common.fail);
|
|
|
|
class Agent extends http.Agent {
|
|
createConnection(options, oncreate) {
|
|
const socket = super.createConnection(options, oncreate);
|
|
socket.once('close', () => server.close());
|
|
return socket;
|
|
}
|
|
}
|
|
|
|
common.refreshTmpDir();
|
|
|
|
server.listen(common.PIPE, common.mustCall(() => {
|
|
const req = http.get({
|
|
agent: new Agent(),
|
|
socketPath: common.PIPE
|
|
});
|
|
|
|
req.abort();
|
|
}));
|