11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// Test https://github.com/nodejs/node/issues/25499 fix.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst { mustCall } = require('../common');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst { Agent, createServer, get } = require('http');
81cb0ef41Sopenharmony_ciconst { strictEqual } = require('assert');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst server = createServer(mustCall((req, res) => {
111cb0ef41Sopenharmony_ci  res.end();
121cb0ef41Sopenharmony_ci}));
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciserver.listen(0, () => {
151cb0ef41Sopenharmony_ci  const agent = new Agent({ keepAlive: true, maxSockets: 1 });
161cb0ef41Sopenharmony_ci  const port = server.address().port;
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci  let socket;
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci  const req = get({ agent, port }, (res) => {
211cb0ef41Sopenharmony_ci    res.on('end', () => {
221cb0ef41Sopenharmony_ci      strictEqual(req.setTimeout(0), req);
231cb0ef41Sopenharmony_ci      strictEqual(socket.listenerCount('timeout'), 1);
241cb0ef41Sopenharmony_ci      agent.destroy();
251cb0ef41Sopenharmony_ci      server.close();
261cb0ef41Sopenharmony_ci    });
271cb0ef41Sopenharmony_ci    res.resume();
281cb0ef41Sopenharmony_ci  });
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci  req.on('socket', (sock) => {
311cb0ef41Sopenharmony_ci    socket = sock;
321cb0ef41Sopenharmony_ci  });
331cb0ef41Sopenharmony_ci});
34