title: How do you follow an HTTP Redirect in Node.js?
body: <p>I want to open a page up in node and process the contents in my application. Something like this seems to work well:</p>
  
  <pre><code>var opts = {host: host, path:pathname, port: 80};
  http.get(opts, function(res) {
    var page = '';
    res.on('data', function (chunk) {
      page += chunk;
    });
    res.on('end', function() {
       // process page
    });
  </code></pre>
  
  <p>This doesn't work, however, if the page returns an 301/302 redirect. How would I do that in a reusable way in case there are multiple redirects? Is there a wrapper module on top of the http to more easily handle processing http responses from a node application? </p>