node-red-contrib-tak-registration 0.1.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.
- package/LICENSE +14 -0
- package/README.md +35 -0
- package/node_modules/adm-zip/LICENSE +21 -0
- package/node_modules/adm-zip/README.md +65 -0
- package/node_modules/adm-zip/adm-zip.js +783 -0
- package/node_modules/adm-zip/headers/entryHeader.js +338 -0
- package/node_modules/adm-zip/headers/index.js +2 -0
- package/node_modules/adm-zip/headers/mainHeader.js +129 -0
- package/node_modules/adm-zip/methods/deflater.js +33 -0
- package/node_modules/adm-zip/methods/index.js +3 -0
- package/node_modules/adm-zip/methods/inflater.js +31 -0
- package/node_modules/adm-zip/methods/zipcrypto.js +170 -0
- package/node_modules/adm-zip/package.json +77 -0
- package/node_modules/adm-zip/util/constants.js +142 -0
- package/node_modules/adm-zip/util/errors.js +35 -0
- package/node_modules/adm-zip/util/fattr.js +79 -0
- package/node_modules/adm-zip/util/fileSystem.js +11 -0
- package/node_modules/adm-zip/util/index.js +4 -0
- package/node_modules/adm-zip/util/utils.js +246 -0
- package/node_modules/adm-zip/zipEntry.js +333 -0
- package/node_modules/adm-zip/zipFile.js +384 -0
- package/node_modules/asynckit/LICENSE +21 -0
- package/node_modules/asynckit/README.md +233 -0
- package/node_modules/asynckit/bench.js +76 -0
- package/node_modules/asynckit/index.js +6 -0
- package/node_modules/asynckit/lib/abort.js +29 -0
- package/node_modules/asynckit/lib/async.js +34 -0
- package/node_modules/asynckit/lib/defer.js +26 -0
- package/node_modules/asynckit/lib/iterate.js +75 -0
- package/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/node_modules/asynckit/lib/state.js +37 -0
- package/node_modules/asynckit/lib/streamify.js +141 -0
- package/node_modules/asynckit/lib/terminator.js +29 -0
- package/node_modules/asynckit/package.json +91 -0
- package/node_modules/asynckit/parallel.js +43 -0
- package/node_modules/asynckit/serial.js +17 -0
- package/node_modules/asynckit/serialOrdered.js +75 -0
- package/node_modules/asynckit/stream.js +21 -0
- package/node_modules/axios/CHANGELOG.md +836 -0
- package/node_modules/axios/LICENSE +19 -0
- package/node_modules/axios/README.md +892 -0
- package/node_modules/axios/SECURITY.md +5 -0
- package/node_modules/axios/UPGRADE_GUIDE.md +162 -0
- package/node_modules/axios/dist/axios.js +2275 -0
- package/node_modules/axios/dist/axios.map +1 -0
- package/node_modules/axios/dist/axios.min.js +2 -0
- package/node_modules/axios/dist/axios.min.map +1 -0
- package/node_modules/axios/index.d.ts +206 -0
- package/node_modules/axios/index.js +1 -0
- package/node_modules/axios/lib/adapters/README.md +37 -0
- package/node_modules/axios/lib/adapters/http.js +363 -0
- package/node_modules/axios/lib/adapters/xhr.js +212 -0
- package/node_modules/axios/lib/axios.js +57 -0
- package/node_modules/axios/lib/cancel/Cancel.js +19 -0
- package/node_modules/axios/lib/cancel/CancelToken.js +119 -0
- package/node_modules/axios/lib/cancel/isCancel.js +5 -0
- package/node_modules/axios/lib/core/Axios.js +148 -0
- package/node_modules/axios/lib/core/InterceptorManager.js +54 -0
- package/node_modules/axios/lib/core/README.md +8 -0
- package/node_modules/axios/lib/core/buildFullPath.js +20 -0
- package/node_modules/axios/lib/core/createError.js +18 -0
- package/node_modules/axios/lib/core/dispatchRequest.js +87 -0
- package/node_modules/axios/lib/core/enhanceError.js +43 -0
- package/node_modules/axios/lib/core/mergeConfig.js +99 -0
- package/node_modules/axios/lib/core/settle.js +25 -0
- package/node_modules/axios/lib/core/transformData.js +22 -0
- package/node_modules/axios/lib/defaults.js +134 -0
- package/node_modules/axios/lib/env/README.md +3 -0
- package/node_modules/axios/lib/env/data.js +3 -0
- package/node_modules/axios/lib/helpers/README.md +7 -0
- package/node_modules/axios/lib/helpers/bind.js +11 -0
- package/node_modules/axios/lib/helpers/buildURL.js +70 -0
- package/node_modules/axios/lib/helpers/combineURLs.js +14 -0
- package/node_modules/axios/lib/helpers/cookies.js +53 -0
- package/node_modules/axios/lib/helpers/deprecatedMethod.js +24 -0
- package/node_modules/axios/lib/helpers/isAbsoluteURL.js +14 -0
- package/node_modules/axios/lib/helpers/isAxiosError.js +11 -0
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +68 -0
- package/node_modules/axios/lib/helpers/normalizeHeaderName.js +12 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +53 -0
- package/node_modules/axios/lib/helpers/spread.js +27 -0
- package/node_modules/axios/lib/helpers/validator.js +82 -0
- package/node_modules/axios/lib/utils.js +349 -0
- package/node_modules/axios/package.json +113 -0
- package/node_modules/axios/tsconfig.json +14 -0
- package/node_modules/axios/tslint.json +6 -0
- package/node_modules/combined-stream/License +19 -0
- package/node_modules/combined-stream/Readme.md +138 -0
- package/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/node_modules/combined-stream/package.json +57 -0
- package/node_modules/combined-stream/yarn.lock +17 -0
- package/node_modules/delayed-stream/.npmignore +1 -0
- package/node_modules/delayed-stream/License +19 -0
- package/node_modules/delayed-stream/Makefile +7 -0
- package/node_modules/delayed-stream/Readme.md +141 -0
- package/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/node_modules/delayed-stream/package.json +62 -0
- package/node_modules/follow-redirects/LICENSE +18 -0
- package/node_modules/follow-redirects/README.md +148 -0
- package/node_modules/follow-redirects/debug.js +15 -0
- package/node_modules/follow-redirects/http.js +1 -0
- package/node_modules/follow-redirects/https.js +1 -0
- package/node_modules/follow-redirects/index.js +569 -0
- package/node_modules/follow-redirects/package.json +95 -0
- package/node_modules/form-data/License +19 -0
- package/node_modules/form-data/README.md.bak +358 -0
- package/node_modules/form-data/Readme.md +358 -0
- package/node_modules/form-data/index.d.ts +62 -0
- package/node_modules/form-data/lib/browser.js +2 -0
- package/node_modules/form-data/lib/form_data.js +501 -0
- package/node_modules/form-data/lib/populate.js +10 -0
- package/node_modules/form-data/package.json +101 -0
- package/node_modules/mime-db/HISTORY.md +499 -0
- package/node_modules/mime-db/LICENSE +22 -0
- package/node_modules/mime-db/README.md +100 -0
- package/node_modules/mime-db/db.json +8471 -0
- package/node_modules/mime-db/index.js +11 -0
- package/node_modules/mime-db/package.json +102 -0
- package/node_modules/mime-types/HISTORY.md +388 -0
- package/node_modules/mime-types/LICENSE +23 -0
- package/node_modules/mime-types/README.md +113 -0
- package/node_modules/mime-types/index.js +188 -0
- package/node_modules/mime-types/package.json +87 -0
- package/node_modules/uuid/CHANGELOG.md +229 -0
- package/node_modules/uuid/CONTRIBUTING.md +18 -0
- package/node_modules/uuid/LICENSE.md +9 -0
- package/node_modules/uuid/README.md +505 -0
- package/node_modules/uuid/dist/bin/uuid +2 -0
- package/node_modules/uuid/dist/esm-browser/index.js +9 -0
- package/node_modules/uuid/dist/esm-browser/md5.js +215 -0
- package/node_modules/uuid/dist/esm-browser/nil.js +1 -0
- package/node_modules/uuid/dist/esm-browser/parse.js +35 -0
- package/node_modules/uuid/dist/esm-browser/regex.js +1 -0
- package/node_modules/uuid/dist/esm-browser/rng.js +19 -0
- package/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
- package/node_modules/uuid/dist/esm-browser/stringify.js +30 -0
- package/node_modules/uuid/dist/esm-browser/v1.js +95 -0
- package/node_modules/uuid/dist/esm-browser/v3.js +4 -0
- package/node_modules/uuid/dist/esm-browser/v35.js +64 -0
- package/node_modules/uuid/dist/esm-browser/v4.js +24 -0
- package/node_modules/uuid/dist/esm-browser/v5.js +4 -0
- package/node_modules/uuid/dist/esm-browser/validate.js +7 -0
- package/node_modules/uuid/dist/esm-browser/version.js +11 -0
- package/node_modules/uuid/dist/esm-node/index.js +9 -0
- package/node_modules/uuid/dist/esm-node/md5.js +13 -0
- package/node_modules/uuid/dist/esm-node/nil.js +1 -0
- package/node_modules/uuid/dist/esm-node/parse.js +35 -0
- package/node_modules/uuid/dist/esm-node/regex.js +1 -0
- package/node_modules/uuid/dist/esm-node/rng.js +12 -0
- package/node_modules/uuid/dist/esm-node/sha1.js +13 -0
- package/node_modules/uuid/dist/esm-node/stringify.js +29 -0
- package/node_modules/uuid/dist/esm-node/v1.js +95 -0
- package/node_modules/uuid/dist/esm-node/v3.js +4 -0
- package/node_modules/uuid/dist/esm-node/v35.js +64 -0
- package/node_modules/uuid/dist/esm-node/v4.js +24 -0
- package/node_modules/uuid/dist/esm-node/v5.js +4 -0
- package/node_modules/uuid/dist/esm-node/validate.js +7 -0
- package/node_modules/uuid/dist/esm-node/version.js +11 -0
- package/node_modules/uuid/dist/index.js +79 -0
- package/node_modules/uuid/dist/md5-browser.js +223 -0
- package/node_modules/uuid/dist/md5.js +23 -0
- package/node_modules/uuid/dist/nil.js +8 -0
- package/node_modules/uuid/dist/parse.js +45 -0
- package/node_modules/uuid/dist/regex.js +8 -0
- package/node_modules/uuid/dist/rng-browser.js +26 -0
- package/node_modules/uuid/dist/rng.js +24 -0
- package/node_modules/uuid/dist/sha1-browser.js +104 -0
- package/node_modules/uuid/dist/sha1.js +23 -0
- package/node_modules/uuid/dist/stringify.js +39 -0
- package/node_modules/uuid/dist/umd/uuid.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidNIL.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidParse.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidStringify.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidValidate.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidVersion.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidv1.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidv3.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidv4.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidv5.min.js +1 -0
- package/node_modules/uuid/dist/uuid-bin.js +85 -0
- package/node_modules/uuid/dist/v1.js +107 -0
- package/node_modules/uuid/dist/v3.js +16 -0
- package/node_modules/uuid/dist/v35.js +78 -0
- package/node_modules/uuid/dist/v4.js +37 -0
- package/node_modules/uuid/dist/v5.js +16 -0
- package/node_modules/uuid/dist/validate.js +17 -0
- package/node_modules/uuid/dist/version.js +21 -0
- package/node_modules/uuid/package.json +164 -0
- package/node_modules/uuid/wrapper.mjs +10 -0
- package/package.json +32 -0
- package/tak-registration.html +111 -0
- package/tak-registration.js +169 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
var Stream = require('stream').Stream;
|
|
2
|
+
var util = require('util');
|
|
3
|
+
|
|
4
|
+
module.exports = DelayedStream;
|
|
5
|
+
function DelayedStream() {
|
|
6
|
+
this.source = null;
|
|
7
|
+
this.dataSize = 0;
|
|
8
|
+
this.maxDataSize = 1024 * 1024;
|
|
9
|
+
this.pauseStream = true;
|
|
10
|
+
|
|
11
|
+
this._maxDataSizeExceeded = false;
|
|
12
|
+
this._released = false;
|
|
13
|
+
this._bufferedEvents = [];
|
|
14
|
+
}
|
|
15
|
+
util.inherits(DelayedStream, Stream);
|
|
16
|
+
|
|
17
|
+
DelayedStream.create = function(source, options) {
|
|
18
|
+
var delayedStream = new this();
|
|
19
|
+
|
|
20
|
+
options = options || {};
|
|
21
|
+
for (var option in options) {
|
|
22
|
+
delayedStream[option] = options[option];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
delayedStream.source = source;
|
|
26
|
+
|
|
27
|
+
var realEmit = source.emit;
|
|
28
|
+
source.emit = function() {
|
|
29
|
+
delayedStream._handleEmit(arguments);
|
|
30
|
+
return realEmit.apply(source, arguments);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
source.on('error', function() {});
|
|
34
|
+
if (delayedStream.pauseStream) {
|
|
35
|
+
source.pause();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return delayedStream;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
Object.defineProperty(DelayedStream.prototype, 'readable', {
|
|
42
|
+
configurable: true,
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function() {
|
|
45
|
+
return this.source.readable;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
DelayedStream.prototype.setEncoding = function() {
|
|
50
|
+
return this.source.setEncoding.apply(this.source, arguments);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
DelayedStream.prototype.resume = function() {
|
|
54
|
+
if (!this._released) {
|
|
55
|
+
this.release();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
this.source.resume();
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
DelayedStream.prototype.pause = function() {
|
|
62
|
+
this.source.pause();
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
DelayedStream.prototype.release = function() {
|
|
66
|
+
this._released = true;
|
|
67
|
+
|
|
68
|
+
this._bufferedEvents.forEach(function(args) {
|
|
69
|
+
this.emit.apply(this, args);
|
|
70
|
+
}.bind(this));
|
|
71
|
+
this._bufferedEvents = [];
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
DelayedStream.prototype.pipe = function() {
|
|
75
|
+
var r = Stream.prototype.pipe.apply(this, arguments);
|
|
76
|
+
this.resume();
|
|
77
|
+
return r;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
DelayedStream.prototype._handleEmit = function(args) {
|
|
81
|
+
if (this._released) {
|
|
82
|
+
this.emit.apply(this, args);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (args[0] === 'data') {
|
|
87
|
+
this.dataSize += args[1].length;
|
|
88
|
+
this._checkIfMaxDataSizeExceeded();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this._bufferedEvents.push(args);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
|
95
|
+
if (this._maxDataSizeExceeded) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (this.dataSize <= this.maxDataSize) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
this._maxDataSizeExceeded = true;
|
|
104
|
+
var message =
|
|
105
|
+
'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'
|
|
106
|
+
this.emit('error', new Error(message));
|
|
107
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_from": "delayed-stream@~1.0.0",
|
|
3
|
+
"_id": "delayed-stream@1.0.0",
|
|
4
|
+
"_inBundle": false,
|
|
5
|
+
"_integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
|
|
6
|
+
"_location": "/node-red-contrib-takfiles/delayed-stream",
|
|
7
|
+
"_phantomChildren": {},
|
|
8
|
+
"_requested": {
|
|
9
|
+
"type": "range",
|
|
10
|
+
"registry": true,
|
|
11
|
+
"raw": "delayed-stream@~1.0.0",
|
|
12
|
+
"name": "delayed-stream",
|
|
13
|
+
"escapedName": "delayed-stream",
|
|
14
|
+
"rawSpec": "~1.0.0",
|
|
15
|
+
"saveSpec": null,
|
|
16
|
+
"fetchSpec": "~1.0.0"
|
|
17
|
+
},
|
|
18
|
+
"_requiredBy": [
|
|
19
|
+
"/node-red-contrib-takfiles/combined-stream"
|
|
20
|
+
],
|
|
21
|
+
"_resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
|
22
|
+
"_shasum": "df3ae199acadfb7d440aaae0b29e2272b24ec619",
|
|
23
|
+
"_spec": "delayed-stream@~1.0.0",
|
|
24
|
+
"_where": "/Users/conway/Projects/DCJNodes/takfile/node_modules/combined-stream",
|
|
25
|
+
"author": {
|
|
26
|
+
"name": "Felix Geisendörfer",
|
|
27
|
+
"email": "felix@debuggable.com",
|
|
28
|
+
"url": "http://debuggable.com/"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/felixge/node-delayed-stream/issues"
|
|
32
|
+
},
|
|
33
|
+
"bundleDependencies": false,
|
|
34
|
+
"contributors": [
|
|
35
|
+
{
|
|
36
|
+
"name": "Mike Atkins",
|
|
37
|
+
"email": "apeherder@gmail.com"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {},
|
|
41
|
+
"deprecated": false,
|
|
42
|
+
"description": "Buffers events from a stream until you are ready to handle them.",
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"fake": "0.2.0",
|
|
45
|
+
"far": "0.0.1"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=0.4.0"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/felixge/node-delayed-stream",
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"main": "./lib/delayed_stream",
|
|
53
|
+
"name": "delayed-stream",
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "git://github.com/felixge/node-delayed-stream.git"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"test": "make test"
|
|
60
|
+
},
|
|
61
|
+
"version": "1.0.0"
|
|
62
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Copyright 2014–present Olivier Lalonde <olalonde@gmail.com>, James Talmage <james@talmage.io>, Ruben Verborgh
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
17
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
18
|
+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
## Follow Redirects
|
|
2
|
+
|
|
3
|
+
Drop-in replacement for Node's `http` and `https` modules that automatically follows redirects.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/follow-redirects)
|
|
6
|
+
[](https://github.com/follow-redirects/follow-redirects/actions)
|
|
7
|
+
[](https://coveralls.io/r/follow-redirects/follow-redirects?branch=master)
|
|
8
|
+
[](https://www.npmjs.com/package/follow-redirects)
|
|
9
|
+
[](https://github.com/sponsors/RubenVerborgh)
|
|
10
|
+
|
|
11
|
+
`follow-redirects` provides [request](https://nodejs.org/api/http.html#http_http_request_options_callback) and [get](https://nodejs.org/api/http.html#http_http_get_options_callback)
|
|
12
|
+
methods that behave identically to those found on the native [http](https://nodejs.org/api/http.html#http_http_request_options_callback) and [https](https://nodejs.org/api/https.html#https_https_request_options_callback)
|
|
13
|
+
modules, with the exception that they will seamlessly follow redirects.
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
const { http, https } = require('follow-redirects');
|
|
17
|
+
|
|
18
|
+
http.get('http://bit.ly/900913', response => {
|
|
19
|
+
response.on('data', chunk => {
|
|
20
|
+
console.log(chunk);
|
|
21
|
+
});
|
|
22
|
+
}).on('error', err => {
|
|
23
|
+
console.error(err);
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
You can inspect the final redirected URL through the `responseUrl` property on the `response`.
|
|
28
|
+
If no redirection happened, `responseUrl` is the original request URL.
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
const request = https.request({
|
|
32
|
+
host: 'bitly.com',
|
|
33
|
+
path: '/UHfDGO',
|
|
34
|
+
}, response => {
|
|
35
|
+
console.log(response.responseUrl);
|
|
36
|
+
// 'http://duckduckgo.com/robots.txt'
|
|
37
|
+
});
|
|
38
|
+
request.end();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Options
|
|
42
|
+
### Global options
|
|
43
|
+
Global options are set directly on the `follow-redirects` module:
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
const followRedirects = require('follow-redirects');
|
|
47
|
+
followRedirects.maxRedirects = 10;
|
|
48
|
+
followRedirects.maxBodyLength = 20 * 1024 * 1024; // 20 MB
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The following global options are supported:
|
|
52
|
+
|
|
53
|
+
- `maxRedirects` (default: `21`) – sets the maximum number of allowed redirects; if exceeded, an error will be emitted.
|
|
54
|
+
|
|
55
|
+
- `maxBodyLength` (default: 10MB) – sets the maximum size of the request body; if exceeded, an error will be emitted.
|
|
56
|
+
|
|
57
|
+
### Per-request options
|
|
58
|
+
Per-request options are set by passing an `options` object:
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
const url = require('url');
|
|
62
|
+
const { http, https } = require('follow-redirects');
|
|
63
|
+
|
|
64
|
+
const options = url.parse('http://bit.ly/900913');
|
|
65
|
+
options.maxRedirects = 10;
|
|
66
|
+
options.beforeRedirect = (options, { headers }) => {
|
|
67
|
+
// Use this to adjust the request options upon redirecting,
|
|
68
|
+
// to inspect the latest response headers,
|
|
69
|
+
// or to cancel the request by throwing an error
|
|
70
|
+
if (options.hostname === "example.com") {
|
|
71
|
+
options.auth = "user:password";
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
http.request(options);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
In addition to the [standard HTTP](https://nodejs.org/api/http.html#http_http_request_options_callback) and [HTTPS options](https://nodejs.org/api/https.html#https_https_request_options_callback),
|
|
78
|
+
the following per-request options are supported:
|
|
79
|
+
- `followRedirects` (default: `true`) – whether redirects should be followed.
|
|
80
|
+
|
|
81
|
+
- `maxRedirects` (default: `21`) – sets the maximum number of allowed redirects; if exceeded, an error will be emitted.
|
|
82
|
+
|
|
83
|
+
- `maxBodyLength` (default: 10MB) – sets the maximum size of the request body; if exceeded, an error will be emitted.
|
|
84
|
+
|
|
85
|
+
- `beforeRedirect` (default: `undefined`) – optionally change the request `options` on redirects, or abort the request by throwing an error.
|
|
86
|
+
|
|
87
|
+
- `agents` (default: `undefined`) – sets the `agent` option per protocol, since HTTP and HTTPS use different agents. Example value: `{ http: new http.Agent(), https: new https.Agent() }`
|
|
88
|
+
|
|
89
|
+
- `trackRedirects` (default: `false`) – whether to store the redirected response details into the `redirects` array on the response object.
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
### Advanced usage
|
|
93
|
+
By default, `follow-redirects` will use the Node.js default implementations
|
|
94
|
+
of [`http`](https://nodejs.org/api/http.html)
|
|
95
|
+
and [`https`](https://nodejs.org/api/https.html).
|
|
96
|
+
To enable features such as caching and/or intermediate request tracking,
|
|
97
|
+
you might instead want to wrap `follow-redirects` around custom protocol implementations:
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
const { http, https } = require('follow-redirects').wrap({
|
|
101
|
+
http: require('your-custom-http'),
|
|
102
|
+
https: require('your-custom-https'),
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Such custom protocols only need an implementation of the `request` method.
|
|
107
|
+
|
|
108
|
+
## Browser Usage
|
|
109
|
+
|
|
110
|
+
Due to the way the browser works,
|
|
111
|
+
the `http` and `https` browser equivalents perform redirects by default.
|
|
112
|
+
|
|
113
|
+
By requiring `follow-redirects` this way:
|
|
114
|
+
```javascript
|
|
115
|
+
const http = require('follow-redirects/http');
|
|
116
|
+
const https = require('follow-redirects/https');
|
|
117
|
+
```
|
|
118
|
+
you can easily tell webpack and friends to replace
|
|
119
|
+
`follow-redirect` by the built-in versions:
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"follow-redirects/http" : "http",
|
|
124
|
+
"follow-redirects/https" : "https"
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
Pull Requests are always welcome. Please [file an issue](https://github.com/follow-redirects/follow-redirects/issues)
|
|
131
|
+
detailing your proposal before you invest your valuable time. Additional features and bug fixes should be accompanied
|
|
132
|
+
by tests. You can run the test suite locally with a simple `npm test` command.
|
|
133
|
+
|
|
134
|
+
## Debug Logging
|
|
135
|
+
|
|
136
|
+
`follow-redirects` uses the excellent [debug](https://www.npmjs.com/package/debug) for logging. To turn on logging
|
|
137
|
+
set the environment variable `DEBUG=follow-redirects` for debug output from just this module. When running the test
|
|
138
|
+
suite it is sometimes advantageous to set `DEBUG=*` to see output from the express server as well.
|
|
139
|
+
|
|
140
|
+
## Authors
|
|
141
|
+
|
|
142
|
+
- [Ruben Verborgh](https://ruben.verborgh.org/)
|
|
143
|
+
- [Olivier Lalonde](mailto:olalonde@gmail.com)
|
|
144
|
+
- [James Talmage](mailto:james@talmage.io)
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
[MIT License](https://github.com/follow-redirects/follow-redirects/blob/master/LICENSE)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var debug;
|
|
2
|
+
|
|
3
|
+
module.exports = function () {
|
|
4
|
+
if (!debug) {
|
|
5
|
+
try {
|
|
6
|
+
/* eslint global-require: off */
|
|
7
|
+
debug = require("debug")("follow-redirects");
|
|
8
|
+
}
|
|
9
|
+
catch (error) { /* */ }
|
|
10
|
+
if (typeof debug !== "function") {
|
|
11
|
+
debug = function () { /* */ };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
debug.apply(null, arguments);
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./").http;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./").https;
|