1'use strict';
2
3const common = require('../common');
4const http = require('http');
5const net = require('net');
6
7function createConnection() {
8  const socket = new net.Socket();
9
10  process.nextTick(function() {
11    socket.destroy(new Error('Oops'));
12  });
13
14  return socket;
15}
16
17{
18  const req = http.get({ createConnection });
19
20  req.on('error', common.expectsError({ name: 'Error', message: 'Oops' }));
21  req.abort();
22}
23
24{
25  class CustomAgent extends http.Agent {}
26  CustomAgent.prototype.createConnection = createConnection;
27
28  const req = http.get({ agent: new CustomAgent() });
29
30  req.on('error', common.expectsError({ name: 'Error', message: 'Oops' }));
31  req.abort();
32}
33