From 766059feb68cff95f3a2569a3260ada00dc07872 Mon Sep 17 00:00:00 2001 From: "matthias.weidemann@gmail.com" Date: Thu, 18 Dec 2014 11:05:31 +0100 Subject: [PATCH] resterl can now also handle data which is not encoded (e.g. images) --- lib/restler.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/restler.js b/lib/restler.js index 715845a..f65602b 100644 --- a/lib/restler.js +++ b/lib/restler.js @@ -134,17 +134,15 @@ mixin(Request.prototype, { self._fireError(err, response); } } else { - var body = ''; - - response.setEncoding('binary'); + var body = new Buffer(''); response.on('data', function(chunk) { - body += chunk; + body = Buffer.concat([body, new Buffer(chunk)]); }); response.on('end', function() { response.rawEncoded = body; - self._decode(new Buffer(body, 'binary'), response, function(err, body) { + self._decode(body, response, function(err, body) { if (err) { self._fireError(err, response); return;