Skip to content

Instantly share code, notes, and snippets.

@itsananderson
Created May 28, 2014 07:23
Show Gist options
  • Save itsananderson/0b1ad56c3487f3820d13 to your computer and use it in GitHub Desktop.
Save itsananderson/0b1ad56c3487f3820d13 to your computer and use it in GitHub Desktop.
var http = require('http');
var responseHandler = function(response) {
if (response.headers.location) {
http.get(response.headers.location, responseHandler);
// If I leave this off, the node process takes ~45 seconds to exit.
// Presumably it's waiting for a listener to attach to the stream
response.on('data', function() {});
} else {
response.pipe(process.stdout);
}
};
http.get(process.argv[2], responseHandler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment