Skip to content

Commit

Permalink
Fixing case where no body exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Sep 9, 2011
1 parent 08ca561 commit 0be269f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.js
Expand Up @@ -314,15 +314,15 @@ Request.prototype.request = function () {
bodyLen += chunk.length
})
options.on("end", function () {
if (Buffer.isBuffer(buffer[0])) {
if (buffer.length && Buffer.isBuffer(buffer[0])) {
var body = new Buffer(bodyLen)
var i = 0
buffer.forEach(function (chunk) {
chunk.copy(body, i, 0, chunk.length)
i += chunk.length
})
response.body = body.toString()
} else {
} else if (buffer.length) {
response.body = buffer.join('')
}

Expand Down

0 comments on commit 0be269f

Please sign in to comment.