mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 15:41:06 +00:00

Move tmpdir functionality to its own module (common/tmpdir). PR-URL: https://github.com/nodejs/node/pull/17856 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
26 lines
566 B
JavaScript
26 lines
566 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
|
|
const server = http.createServer(common.mustNotCall());
|
|
|
|
class Agent extends http.Agent {
|
|
createConnection(options, oncreate) {
|
|
const socket = super.createConnection(options, oncreate);
|
|
socket.once('close', () => server.close());
|
|
return socket;
|
|
}
|
|
}
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
server.listen(common.PIPE, common.mustCall(() => {
|
|
const req = http.get({
|
|
agent: new Agent(),
|
|
socketPath: common.PIPE
|
|
});
|
|
|
|
req.abort();
|
|
}));
|