diff options
Diffstat (limited to 'node_modules/npm-registry-client/lib/request.js')
-rw-r--r-- | node_modules/npm-registry-client/lib/request.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/node_modules/npm-registry-client/lib/request.js b/node_modules/npm-registry-client/lib/request.js index c516176e2..42221fe0d 100644 --- a/node_modules/npm-registry-client/lib/request.js +++ b/node_modules/npm-registry-client/lib/request.js @@ -8,7 +8,8 @@ var url = require("url") , request = require("request") , retry = require("retry") -function regRequest (method, where, what, etag, nofollow, cb_) { +function regRequest (method, where, what, etag, nofollow, reauthed, cb_) { + if (typeof cb_ !== "function") cb_ = reauthed, reauthed = false if (typeof cb_ !== "function") cb_ = nofollow, nofollow = false if (typeof cb_ !== "function") cb_ = etag, etag = null if (typeof cb_ !== "function") cb_ = what, what = null @@ -84,7 +85,7 @@ function regRequest (method, where, what, etag, nofollow, cb_) { this.conf.set('_token', this.couchLogin.token) return regRequest.call(this, method, where, what, - etag, nofollow, cb_) + etag, nofollow, reauthed, cb_) }.bind(this)) } } @@ -110,7 +111,6 @@ function regRequest (method, where, what, etag, nofollow, cb_) { }) var self = this - var reauthed = false; operation.attempt(function (currentAttempt) { self.log.info("trying", "registry request attempt " + currentAttempt + " at " + (new Date()).toLocaleTimeString()) @@ -129,6 +129,8 @@ function regRequest (method, where, what, etag, nofollow, cb_) { ( statusCode === 401 || statusCode === 400 || statusCode === 403 ) + if (reauth) + reauthed = true var timeout = statusCode === 408 var serverError = statusCode >= 500 @@ -136,7 +138,8 @@ function regRequest (method, where, what, etag, nofollow, cb_) { if (reauth && this.conf.get('_auth') && this.conf.get('_token')) { this.conf.del('_token') this.couchLogin.token = null - return regRequest.call(this, method, where, what, etag, nofollow, cb_) + return regRequest.call(this, method, where, what, + etag, nofollow, reauthed, cb_) } if (er && statusRetry && operation.retry(er)) { self.log.info("retry", "will retry, error on last attempt: " + er) |