Skip to content

Commit

Permalink
"false" disables retry
Browse files Browse the repository at this point in the history
  • Loading branch information
13W committed Dec 9, 2013
1 parent 0d7b4ba commit e440aa3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/index.restdown
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ Options:
||gzip||Object||Will compress data when sent using `content-encoding: gzip`||
||headers||Object||HTTP headers to set in all requests||
||log||Object||[bunyan](https://github.com/trentm/node-bunyan) instance||
||retry||Object||options to provide to node-retry; defaults to 3 retries||
||retry||Object||options to provide to node-retry;"false" disables retry; defaults to 4 retries||
||signRequest||Function||synchronous callback for interposing headers before request is sent||
||url||String||Fully-qualified URL to connect to||
||userAgent||String||user-agent string to use; restify inserts one, but you can override it||
Expand Down
19 changes: 12 additions & 7 deletions lib/clients/http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ var VERSION = JSON.parse(fs.readFileSync(require('path').normalize(__dirname + '

function cloneRetryOptions(options, defaults) {
if (options === false) {
return ({
minTimeout: 1,
maxTimeout: 2,
retries: 1
});
return false;
}

assert.optionalObject(options, 'options.retry');
Expand Down Expand Up @@ -426,6 +422,11 @@ HttpClient.prototype.request = function request(opts, cb) {

cb = once(cb);

if (opts.retry === false) {
rawRequest(opts, cb);
return;
}

var call;
var retry = cloneRetryOptions(opts.retry);

Expand Down Expand Up @@ -462,11 +463,15 @@ HttpClient.prototype._options = function (method, options) {
pfx: options.pfx || self.pfx,
rejectUnauthorized: options.rejectUnauthorized ||
self.rejectUnauthorized,
retry: options.retry || self.retry,
retry: options.retry !== false ? options.retry : false,
signRequest: options.signRequest || self.signRequest
};

// Backwards compatibility with restify < 1.0
if (!opts.retry && opts.retry !== false)
opts.retry = self.retry;


// Backwards compatibility with restify < 1.0
if (options.query &&
Object.keys(options.query).length &&
opts.path.indexOf('?') === -1) {
Expand Down

0 comments on commit e440aa3

Please sign in to comment.