Inverting the branch logic for easier reading

This commit is contained in:
ciaranj 2011-06-23 22:18:11 +01:00
parent c78a9ca129
commit 3ed11c05bd

View File

@ -350,7 +350,9 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
data+=chunk;
});
response.on('end', function () {
if (!( response.statusCode >= 200 && response.statusCode <= 299 )) {
if ( response.statusCode >= 200 && response.statusCode <= 299 ) {
callback(null, data, response);
} else {
// Follow 302 redirects with Location HTTP header
if(response.statusCode == 302 && response.headers && response.headers.location) {
self._performSecureRequest( oauth_token, oauth_token_secret, method, response.headers.location, extra_params, post_body, post_content_type, callback);
@ -358,8 +360,6 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
else {
callback({ statusCode: response.statusCode, data: data }, data, response);
}
} else {
callback(null, data, response);
}
});
});