Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Only use setTimeout if timeout value is > 0.

  • Loading branch information...
commit aef534a2154c5238235994381e6728ec28a7946c 1 parent 7e1fccc
@yhahn yhahn authored
Showing with 10 additions and 8 deletions.
  1. +10 −8 lib/node-get/node-get.js
View
18 lib/node-get/node-get.js
@@ -155,14 +155,16 @@ Get.prototype.perform = function(callback, times) {
// Enforce a timeout of 10 seconds.
// Add a no-op version of setTimeout for node <= 0.4.x.
- clientrequest.setTimeout = clientrequest.setTimeout || function() {};
- clientrequest.setTimeout(this.timeout, function() {
- clientrequest.connection.end();
- if (++error > 1) return;
- var err = new Error('Timed out after ' + this.timeout + 'ms');
- err.status = 504; // HTTP status code for "Gateway Timeout".
- return callback.call(this, err);
- }.bind(this));
+ if (this.timeout > 0) {
+ clientrequest.setTimeout = clientrequest.setTimeout || function() {};
+ clientrequest.setTimeout(this.timeout, function() {
+ clientrequest.connection.end();
+ if (++error > 1) return;
+ var err = new Error('Timed out after ' + this.timeout + 'ms');
+ err.status = 504; // HTTP status code for "Gateway Timeout".
+ return callback.call(this, err);
+ }.bind(this));
+ }
// TODO: fix when/if gzip is supported.
// If a proxy is defined, ask for the full requested URL,

0 comments on commit aef534a

Please sign in to comment.
Something went wrong with that request. Please try again.