xref: /third_party/node/test/parallel/test-http-agent-uninitialized.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst http = require('http');
51cb0ef41Sopenharmony_ciconst net = require('net');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst agent = new http.Agent({
81cb0ef41Sopenharmony_ci  keepAlive: true,
91cb0ef41Sopenharmony_ci});
101cb0ef41Sopenharmony_ciconst socket = new net.Socket();
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustCall((req, res) => {
131cb0ef41Sopenharmony_ci  res.end();
141cb0ef41Sopenharmony_ci})).listen(0, common.mustCall(() => {
151cb0ef41Sopenharmony_ci  const req = new http.ClientRequest(`http://localhost:${server.address().port}/`);
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  // Manually add the socket without a _handle.
181cb0ef41Sopenharmony_ci  agent.freeSockets[agent.getName(req)] = [socket];
191cb0ef41Sopenharmony_ci  // Now force the agent to use the socket and check that _handle exists before
201cb0ef41Sopenharmony_ci  // calling asyncReset().
211cb0ef41Sopenharmony_ci  agent.addRequest(req, {});
221cb0ef41Sopenharmony_ci  req.on('response', common.mustCall(() => {
231cb0ef41Sopenharmony_ci    server.close();
241cb0ef41Sopenharmony_ci  }));
251cb0ef41Sopenharmony_ci  req.end();
261cb0ef41Sopenharmony_ci}));
27

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