From 9be8d3538541b2d7779205989aaa2a2d31781aee Mon Sep 17 00:00:00 2001 From: Thiago Sanches Date: Fri, 1 Mar 2019 10:13:40 -0300 Subject: [PATCH] Add a parameter to overwrite the default response timeout. Noticed that for some BLC_UNKNOWN errors it were related to the response timeout, in order to avoid that added an option to overwrite the default response timeout. --- bin/blc | 0 lib/cli.js | 11 ++++++++++- lib/internal/checkUrl.js | 3 ++- lib/internal/defaultOptions.js | 3 ++- 4 files changed, 14 insertions(+), 3 deletions(-) mode change 100644 => 100755 bin/blc diff --git a/bin/blc b/bin/blc old mode 100644 new mode 100755 diff --git a/lib/cli.js b/lib/cli.js index 70a0ad51..17294cad 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -32,6 +32,14 @@ function cli() name: "blc", options: { + "response-timeout": + { + rename: "responseTimeout", + info: "Set the request's response timeout (in milliseconds).", + type: Number, + default: defaultOptions.responseTimeout + + }, "exclude": { rename: "excludedKeywords", @@ -169,7 +177,8 @@ cli.prototype.input = function(args, showArgs) maxSockets: args.maxSockets, maxSocketsPerHost: args.maxSocketsPerHost, requestMethod: args.get!==true ? "head" : "get", - userAgent: args.userAgent + userAgent: args.userAgent, + responseTimeout: args.responseTimeout }, { excludeCachedLinks: args.verbose!==true, diff --git a/lib/internal/checkUrl.js b/lib/internal/checkUrl.js index 5130761f..334f64e8 100644 --- a/lib/internal/checkUrl.js +++ b/lib/internal/checkUrl.js @@ -55,7 +55,8 @@ function checkUrl(link, baseUrl, cache, options, retry) { discardResponse: true, headers: { "user-agent":options.userAgent }, - method: retry!==405 ? options.requestMethod : "get" + method: retry!==405 ? options.requestMethod : "get", + responseTimeout: options.responseTimeout }) .then( function(response) { diff --git a/lib/internal/defaultOptions.js b/lib/internal/defaultOptions.js index c8936ce9..fae62fdb 100644 --- a/lib/internal/defaultOptions.js +++ b/lib/internal/defaultOptions.js @@ -21,7 +21,8 @@ var defaultOptions = requestMethod: "head", retry405Head: true, tags: require("./tags"), - userAgent: userAgent(pkg.name, pkg.version) + userAgent: userAgent(pkg.name, pkg.version), + responseTimeout: 120000 };