summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-client-abort-response-event.js
blob: c8a80f57884fb7aa64d7d0843fb53fd91a0848b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict';
const common = require('../common');
const http = require('http');
const net = require('net');
const server = http.createServer(function(req, res) {
  res.end();
});

server.listen(0, common.mustCall(function() {
  const req = http.request({
    port: this.address().port
  }, common.mustCall());

  req.on('abort', common.mustCall(function() {
    server.close();
  }));

  req.end();
  req.abort();

  req.emit('response', new http.IncomingMessage(new net.Socket()));
}));