mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
2ca22aacbd
ClientRequest will now emit an abort event the first time abort() is called. Semver: Minor Fixes: https://github.com/joyent/node/issues/9278 PR-URL: https://github.com/iojs/io.js/pull/945 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
29 lines
554 B
JavaScript
29 lines
554 B
JavaScript
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);
|
|
})
|