forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: emit abort event from ClientRequest
ClientRequest will now emit an abort event the first time abort() is called. Semver: Minor Fixes: nodejs/node-v0.x-archive#9278 PR-URL: nodejs#945 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chris Dickinson <[email protected]>
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
}) |