xref: /third_party/node/test/parallel/test-http-agent-timeout-option.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst { mustCall } = require('../common');
41cb0ef41Sopenharmony_ciconst { strictEqual } = require('assert');
51cb0ef41Sopenharmony_ciconst { Agent, get } = require('http');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci// Test that the listener that forwards the `'timeout'` event from the socket to
81cb0ef41Sopenharmony_ci// the `ClientRequest` instance is added to the socket when the `timeout` option
91cb0ef41Sopenharmony_ci// of the `Agent` is set.
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst request = get({
121cb0ef41Sopenharmony_ci  agent: new Agent({ timeout: 50 }),
131cb0ef41Sopenharmony_ci  lookup: () => {}
141cb0ef41Sopenharmony_ci});
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_cirequest.on('socket', mustCall((socket) => {
171cb0ef41Sopenharmony_ci  strictEqual(socket.timeout, 50);
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci  const listeners = socket.listeners('timeout');
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci  strictEqual(listeners.length, 2);
221cb0ef41Sopenharmony_ci  strictEqual(listeners[1], request.timeoutCb);
231cb0ef41Sopenharmony_ci}));
24

Indexes created Thu Nov 07 10:32:03 CST 2024