Skip to content

Instantly share code, notes, and snippets.

@polotek
Created January 21, 2011 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polotek/789962 to your computer and use it in GitHub Desktop.
Save polotek/789962 to your computer and use it in GitHub Desktop.
var req = http.request(options, function(res) {
if(res.statusCode >= 300 && < 400) {
return http.FOLLOW_REDIRECT;
}
if(res.statusCode >= 500 && retrys--) {
return http.RETRY;
}
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
var req = http.request(options, function(res) {
if(res.statusCode >= 300 && < 400) {
return http.FOLLOW_REDIRECT;
}
if(res.statusCode >= 500) {
log('Log failure', function() {
if(retry--)
req.retry();
});
return;
}
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment