11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst http = require('http');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_cilet socketsCreated = 0;
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciclass Agent extends http.Agent {
91cb0ef41Sopenharmony_ci  createConnection(options, oncreate) {
101cb0ef41Sopenharmony_ci    const socket = super.createConnection(options, oncreate);
111cb0ef41Sopenharmony_ci    socketsCreated++;
121cb0ef41Sopenharmony_ci    return socket;
131cb0ef41Sopenharmony_ci  }
141cb0ef41Sopenharmony_ci}
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciconst server = http.createServer((req, res) => res.end());
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciconst socketPath = common.PIPE;
191cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir');
201cb0ef41Sopenharmony_citmpdir.refresh();
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciserver.listen(socketPath, common.mustCall(() => {
231cb0ef41Sopenharmony_ci  const agent = new Agent({
241cb0ef41Sopenharmony_ci    keepAlive: true,
251cb0ef41Sopenharmony_ci    maxSockets: 1
261cb0ef41Sopenharmony_ci  });
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci  http.get({ agent, socketPath }, (res) => res.resume());
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci  const req = http.get({ agent, socketPath }, common.mustNotCall());
311cb0ef41Sopenharmony_ci  req.abort();
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci  http.get({ agent, socketPath }, common.mustCall((res) => {
341cb0ef41Sopenharmony_ci    res.resume();
351cb0ef41Sopenharmony_ci    assert.strictEqual(socketsCreated, 1);
361cb0ef41Sopenharmony_ci    agent.destroy();
371cb0ef41Sopenharmony_ci    server.close();
381cb0ef41Sopenharmony_ci  }));
391cb0ef41Sopenharmony_ci}));
40