Created
May 28, 2014 07:23
-
-
Save itsananderson/0b1ad56c3487f3820d13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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