1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4const http = require('http'); 5 6let socketsCreated = 0; 7 8class Agent extends http.Agent { 9 createConnection(options, oncreate) { 10 const socket = super.createConnection(options, oncreate); 11 socketsCreated++; 12 return socket; 13 } 14} 15 16const server = http.createServer((req, res) => res.end()); 17 18const socketPath = common.PIPE; 19const tmpdir = require('../common/tmpdir'); 20tmpdir.refresh(); 21 22server.listen(socketPath, common.mustCall(() => { 23 const agent = new Agent({ 24 keepAlive: true, 25 maxSockets: 1 26 }); 27 28 http.get({ agent, socketPath }, (res) => res.resume()); 29 30 const req = http.get({ agent, socketPath }, common.mustNotCall()); 31 req.abort(); 32 33 http.get({ agent, socketPath }, common.mustCall((res) => { 34 res.resume(); 35 assert.strictEqual(socketsCreated, 1); 36 agent.destroy(); 37 server.close(); 38 })); 39})); 40