Skip to content

Commit

Permalink
Fixes request#144.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Feb 18, 2012
1 parent 3c6581a commit 54e6aca
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,8 @@ Request.prototype.write = function () {
if (!this.req) throw new Error("This request has been piped before http.request() was called.")
this.req.write.apply(this.req, arguments)
}
Request.prototype.end = function () {
Request.prototype.end = function (chunk) {
if (chunk) this.write(chunk)
if (!this._started) this.start()
if (!this.req) throw new Error("This request has been piped before http.request() was called.")
this.req.end.apply(this.req, arguments)
Expand All @@ -652,6 +653,9 @@ Request.prototype.resume = function () {
if (!this.response) throw new Error("This request has been piped before http.request() was called.")
this.response.resume.apply(this.response, arguments)
}
Request.prototype.destroy = function () {
if (!this._ended) this.end()
}

function request (options, callback) {
if (typeof options === 'string') options = {uri:options}
Expand Down

0 comments on commit 54e6aca

Please sign in to comment.