From 3ed11c05bd1ad39e99cafafcbc7f3732947129dd Mon Sep 17 00:00:00 2001 From: ciaranj Date: Thu, 23 Jun 2011 22:18:11 +0100 Subject: [PATCH] Inverting the branch logic for easier reading --- lib/oauth.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/oauth.js b/lib/oauth.js index 958139c..e407180 100644 --- a/lib/oauth.js +++ b/lib/oauth.js @@ -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); } }); });