Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added support for timeouts #4

Merged
merged 1 commit into from

2 participants

@cmtt

For supporting timeouts, options.timeout was added in this pull request.

@SaltwaterC SaltwaterC merged commit 3fcd6d5 into SaltwaterC:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 6, 2011
  1. Adding support for timeouts

    cmtt authored
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 1 deletion.
  1. +16 −1 lib/http-get.js
View
17 lib/http-get.js
@@ -38,7 +38,7 @@ https.head = function (options, cb) {
return req;
};
/**
- * Makes all the HTTP request headers to be specified as lower case
+ * Makes all the HTTP request headers to be specified as lower case
* @param hdr
* @returns hdr
*/
@@ -464,6 +464,13 @@ var get = function (options, file, cb, reqId) {
req.on('error', function (err) {
cb(err);
});
+ if (typeof options.timeout === 'number') {
+ req.setTimeout(options.timeout,function() {
+ cb(new Error('Timeout while downloading ' + options.url));
+ req.abort();
+ return;
+ });
+ };
req.end();
};
processRequest(client.get(opt));
@@ -535,7 +542,15 @@ var head = function (options, cb, reqId) {
req.on('error', function (err) {
cb(err);
});
+ if (typeof options.timeout === 'number') {
+ req.setTimeout(options.timeout,function() {
+ cb(new Error('Timeout while downloading ' + options.url));
+ req.abort();
+ return;
+ });
+ };
req.end();
+
};
processRequest(client.head(opt));
};
Something went wrong with that request. Please try again.