summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-client-abort-event.js
blob: 1549d06101a6470b7d05baf979ce1fa99bb7ec22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var assert = require('assert');
var http = require('http');
var common = require('../common');
var server = http.createServer(function(req, res) {
  res.end();
});
var count = 0;
server.listen(common.PORT, function() {
  var req = http.request({
    port: common.PORT
  }, function() {
    assert(false, 'should not receive data');
  });

  req.on('abort', function() {
    // should only be emitted once
    count++;
    server.close();
  });

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

process.on('exit', function() {
  assert.equal(count, 1);
})