http: emit abort event from ClientRequest by evanlucas · Pull Request #945 · nodejs/node · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/api/http.markdown
6 changes: 6 additions & 0 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ ClientRequest.prototype._implicitHeader = function() {
};

ClientRequest.prototype.abort = function() {
var self = this;
if (this.aborted === undefined) {
process.nextTick(function() {
self.emit('abort');
});
}
// Mark as aborting so we can avoid sending queued request data
// This is used as a truthy flag elsewhere. The use of Date.now is for
// debugging purposes only.
Expand Down
28 changes: 28 additions & 0 deletions test/parallel/test-http-client-abort-event.js