follow-redirects 1.6.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of follow-redirects might be problematic. Click here for more details.
- package/index.js +34 -1
- package/package.json +3 -2
package/index.js
CHANGED
@@ -147,10 +147,43 @@ RedirectableRequest.prototype.removeHeader = function (name) {
|
|
147
147
|
this._currentRequest.removeHeader(name);
|
148
148
|
};
|
149
149
|
|
150
|
+
// Global timeout for all underlying requests
|
151
|
+
RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
|
152
|
+
if (callback) {
|
153
|
+
this.once("timeout", callback);
|
154
|
+
}
|
155
|
+
|
156
|
+
if (this.socket) {
|
157
|
+
startTimer(this, msecs);
|
158
|
+
}
|
159
|
+
else {
|
160
|
+
var self = this;
|
161
|
+
this._currentRequest.once("socket", function () {
|
162
|
+
startTimer(self, msecs);
|
163
|
+
});
|
164
|
+
}
|
165
|
+
|
166
|
+
this.once("response", clearTimer);
|
167
|
+
this.once("error", clearTimer);
|
168
|
+
|
169
|
+
return this;
|
170
|
+
};
|
171
|
+
|
172
|
+
function startTimer(request, msecs) {
|
173
|
+
clearTimeout(request._timeout);
|
174
|
+
request._timeout = setTimeout(function () {
|
175
|
+
request.emit("timeout");
|
176
|
+
}, msecs);
|
177
|
+
}
|
178
|
+
|
179
|
+
function clearTimer() {
|
180
|
+
clearTimeout(this._timeout);
|
181
|
+
}
|
182
|
+
|
150
183
|
// Proxy all other public ClientRequest methods
|
151
184
|
[
|
152
185
|
"abort", "flushHeaders", "getHeader",
|
153
|
-
"setNoDelay", "setSocketKeepAlive",
|
186
|
+
"setNoDelay", "setSocketKeepAlive",
|
154
187
|
].forEach(function (method) {
|
155
188
|
RedirectableRequest.prototype[method] = function (a, b) {
|
156
189
|
return this._currentRequest[method](a, b);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "follow-redirects",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.7.0",
|
4
4
|
"description": "HTTP and HTTPS modules that follow redirects.",
|
5
5
|
"main": "index.js",
|
6
6
|
"files": [
|
@@ -37,13 +37,14 @@
|
|
37
37
|
"James Talmage <james@talmage.io>"
|
38
38
|
],
|
39
39
|
"dependencies": {
|
40
|
-
"debug": "
|
40
|
+
"debug": "^3.2.6"
|
41
41
|
},
|
42
42
|
"devDependencies": {
|
43
43
|
"concat-stream": "^1.6.0",
|
44
44
|
"coveralls": "^3.0.2",
|
45
45
|
"eslint": "^4.19.1",
|
46
46
|
"express": "^4.16.2",
|
47
|
+
"lolex": "^3.0.0",
|
47
48
|
"mocha": "^5.0.0",
|
48
49
|
"nyc": "^11.8.0"
|
49
50
|
},
|