Skip to content

Commit

Permalink
Added drain event and returning the boolean from write to proper hand…
Browse files Browse the repository at this point in the history
…le back pressure when piping.
  • Loading branch information
mafintosh committed Jun 25, 2012
1 parent 7165c86 commit 5a7ca9b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ Request.prototype.start = function () {
}

self.req.on('error', self.clientErrorHandler)
self.req.on('drain', function() {
self.emit('drain')
})

self.emit('request', self.req)
}
Expand Down Expand Up @@ -807,7 +810,7 @@ Request.prototype.pipe = function (dest, opts) {
}
Request.prototype.write = function () {
if (!this._started) this.start()
this.req.write.apply(this.req, arguments)
return this.req.write.apply(this.req, arguments)
}
Request.prototype.end = function (chunk) {
if (chunk) this.write(chunk)
Expand Down

0 comments on commit 5a7ca9b

Please sign in to comment.