xref: /third_party/node/test/parallel/test-http-client-abort3.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_cifunction createConnection() {
81cb0ef41Sopenharmony_ci  const socket = new net.Socket();
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci  process.nextTick(function() {
111cb0ef41Sopenharmony_ci    socket.destroy(new Error('Oops'));
121cb0ef41Sopenharmony_ci  });
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci  return socket;
151cb0ef41Sopenharmony_ci}
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci{
181cb0ef41Sopenharmony_ci  const req = http.get({ createConnection });
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci  req.on('error', common.expectsError({ name: 'Error', message: 'Oops' }));
211cb0ef41Sopenharmony_ci  req.abort();
221cb0ef41Sopenharmony_ci}
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci{
251cb0ef41Sopenharmony_ci  class CustomAgent extends http.Agent {}
261cb0ef41Sopenharmony_ci  CustomAgent.prototype.createConnection = createConnection;
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci  const req = http.get({ agent: new CustomAgent() });
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci  req.on('error', common.expectsError({ name: 'Error', message: 'Oops' }));
311cb0ef41Sopenharmony_ci  req.abort();
321cb0ef41Sopenharmony_ci}
33

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