title: Node.js: Howto close response/request while retrieving data (chuncks)
body: <p>I'm building an application in node.js wich loads several pages an analyses the contents.</p>
  
  <p>Because node.js sends chunks I can analyse the chunks. If a chunk contains for example index,nofollow I want to close that connection and go on with the rest.</p>
  
  <pre><code>var host  = 'example.com',
      total = '',
      http  = require('http');
  
  var req = http.request({hostname: host, port: 80, path: '/'}, function(res) {
      res.on('data', function(chunk) {
          total += chunk;
          if(chunk.toString().indexOf('index,nofollow') == -1) {
              // do stuff
          } else {
              /*
               * WHAT TO DO HERE???
               * how to close this res/req?
               * close this request (goto res.end or req.end????
               */
          }
      }).on('end', function() {
          // do stuff
      });
  }).on('error', function(e) {
      // do stuff
      console.log("Got error: " + e.message);
  });
  </code></pre>
  
  <p>The only thing I can't figure out is to quit that connection. Or stop retrieving data because i don't need it..</p>
  
  <p>req.end(); doesn't work.. it keeps continuing with retrieving data/chunks..
  (in my test I get 14 chunks, but at the first chunk I already know i don't need the other chunks, so I want to quit the request/response).</p>
  
  <p>I now have a boolean that skips analyzing the others chunks, but in my opinion I'm better of skipping retrieving the data?</p>
  
  <p>What function to call? Or is it impossible because it needs to retrieve everything?</p>