11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci'use strict';
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst common = require('../common');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ciconst http = require('http');
81cb0ef41Sopenharmony_ciconst { kTimeout } = require('internal/timers');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst server = http.createServer((req, res) => {
111cb0ef41Sopenharmony_ci  // This space is intentionally left blank.
121cb0ef41Sopenharmony_ci});
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciserver.listen(0, common.localhostIPv4, common.mustCall(() => {
151cb0ef41Sopenharmony_ci  const port = server.address().port;
161cb0ef41Sopenharmony_ci  const req = http.get(`http://${common.localhostIPv4}:${port}`);
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci  req.setTimeout(1);
191cb0ef41Sopenharmony_ci  req.on('socket', common.mustCall((socket) => {
201cb0ef41Sopenharmony_ci    assert.strictEqual(socket[kTimeout], null);
211cb0ef41Sopenharmony_ci    socket.on('connect', common.mustCall(() => {
221cb0ef41Sopenharmony_ci      assert.strictEqual(socket[kTimeout]._idleTimeout, 1);
231cb0ef41Sopenharmony_ci    }));
241cb0ef41Sopenharmony_ci  }));
251cb0ef41Sopenharmony_ci  req.on('timeout', common.mustCall(() => req.abort()));
261cb0ef41Sopenharmony_ci  req.on('error', common.mustCall((err) => {
271cb0ef41Sopenharmony_ci    assert.strictEqual(err.message, 'socket hang up');
281cb0ef41Sopenharmony_ci    server.close();
291cb0ef41Sopenharmony_ci  }));
301cb0ef41Sopenharmony_ci}));
31