diff --git a/index.js b/index.js index 4fc55f0..bc8155a 100644 --- a/index.js +++ b/index.js @@ -207,13 +207,13 @@ prerender.getPrerenderedPageResponse = function(req, callback) { prerender.gunzipResponse = function(response, callback) { var gunzip = zlib.createGunzip() - , content = ''; + , contentChunks = []; gunzip.on('data', function(chunk) { - content += chunk; + contentChunks.push(chunk); }); gunzip.on('end', function() { - response.body = content; + response.body = Buffer.concat(contentChunks).toString(); delete response.headers['content-encoding']; delete response.headers['content-length']; callback(null, response); @@ -226,13 +226,13 @@ prerender.gunzipResponse = function(response, callback) { }; prerender.plainResponse = function(response, callback) { - var content = ''; + var contentChunks = []; response.on('data', function(chunk) { - content += chunk; + contentChunks.push(chunk); }); response.on('end', function() { - response.body = content; + response.body = Buffer.concat(contentChunks).toString(); callback(null, response); }); };