title: NodeJS HTTP GET returns empty body
body: <p>Here's a NodeJS code snippet I'm debugging. The url is correct, and a GET request to it with <a href="https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop" rel="nofollow noreferrer">Postman</a> returns a <code>200 OK</code> with the following headers. The response body is a valid JSON string.</p>
  
  <h2>Headers (arrows represent column divisors)</h2>
  
  <pre><code>Accept-Ranges →bytes
  Age →0
  Cache-Control →max-age=300
  Connection →keep-alive
  Content-Encoding →gzip
  Content-Length →255
  Content-Type →application/json
  Date →Tue, 24 Jan 2017 22:37:28 GMT
  Expires →Tue, 24 Jan 2017 17:47:43 GMT
  Last-Modified →Tue, 24 Jan 2017 01:03:08 GMT
  Server →nginx
  Vary →Accept-Encoding
  Via →1.1 varnish
  X-Cache →HIT
  X-Cache-Hits →1
  X-Served-By →cache-yul8926-YUL
  X-Timer →S1485297448.259768,VS0,VE89
  </code></pre>
  
  <h2>The problem:</h2>
  
  <p>I've discovered that <code>res.on('data', function(chunk) {</code> never gets called which causes <code>body</code> to remain empty.</p>
  
  <p>When <code>res.on('end', function() {</code> is called  <code>body</code> still has length = 0. Any ideas why the data callback is not getting called?</p>
  
  <pre><code>http.get(url, function(res) {
      var body = '';
  
      res.on('data', function(chunk) {
        body += chunk;
      });
  
      res.on('end', function() {
        var data = JSON.parse(body);
        cb(data, undefined);
      });
  }).on('error', function(err) {
    console.log("Something went wrong");
    console.log(err);
  });
  </code></pre>
  
  <p>Also worth nothing, <code>cb</code> is a callback function defined outside of this snippet.</p>