Get the whole response body when the response is chunked?

http, node.js

Solution

request.on('response', function (response) {
  var body = '';
  response.on('data', function (chunk) {
    body += chunk;
  });
  response.on('end', function () {
    console.log('BODY: ' + body);
  });
});
request.end();

Problem

I'm making a HTTP request and listen for "data": ``` response.on("data", function (data) { ... }) ``` The problem is that the response is chunked so the "data" is just a piece of the body sent back. How do I get the whole body sent back?

Original source