mw-common-components 0.0.1-security → 99.99.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mw-common-components might be problematic. Click here for more details.
- package/README.md +3 -3
- package/config/dev.env.js +37 -0
- package/config/hap.amend.js +29 -0
- package/config/index.js +8 -0
- package/config/prod.env.js +28 -0
- package/index.d.ts +130 -0
- package/index.js +1 -0
- package/package.json +44 -3
- package/src/index.html +12 -0
- package/src/lib/app.js +103 -0
- package/src/lib/axios/CHANGELOG.md +245 -0
- package/src/lib/axios/LICENSE +19 -0
- package/src/lib/axios/README.md +625 -0
- package/src/lib/axios/UPGRADE_GUIDE.md +162 -0
- package/src/lib/axios/dist/axios.js +1603 -0
- package/src/lib/axios/dist/axios.map +1 -0
- package/src/lib/axios/dist/axios.min.js +9 -0
- package/src/lib/axios/dist/axios.min.map +1 -0
- package/src/lib/axios/index.d.ts +131 -0
- package/src/lib/axios/index.js +1 -0
- package/src/lib/axios/lib/adapters/README.md +37 -0
- package/src/lib/axios/lib/adapters/http.js +237 -0
- package/src/lib/axios/lib/adapters/xhr.js +180 -0
- package/src/lib/axios/lib/axios.js +52 -0
- package/src/lib/axios/lib/cancel/Cancel.js +19 -0
- package/src/lib/axios/lib/cancel/CancelToken.js +57 -0
- package/src/lib/axios/lib/cancel/isCancel.js +5 -0
- package/src/lib/axios/lib/core/Axios.js +79 -0
- package/src/lib/axios/lib/core/InterceptorManager.js +52 -0
- package/src/lib/axios/lib/core/README.md +7 -0
- package/src/lib/axios/lib/core/createError.js +18 -0
- package/src/lib/axios/lib/core/dispatchRequest.js +86 -0
- package/src/lib/axios/lib/core/enhanceError.js +21 -0
- package/src/lib/axios/lib/core/settle.js +26 -0
- package/src/lib/axios/lib/core/transformData.js +20 -0
- package/src/lib/axios/lib/defaults.js +96 -0
- package/src/lib/axios/lib/helpers/README.md +7 -0
- package/src/lib/axios/lib/helpers/bind.js +11 -0
- package/src/lib/axios/lib/helpers/btoa.js +36 -0
- package/src/lib/axios/lib/helpers/buildURL.js +66 -0
- package/src/lib/axios/lib/helpers/combineURLs.js +14 -0
- package/src/lib/axios/lib/helpers/cookies.js +53 -0
- package/src/lib/axios/lib/helpers/deprecatedMethod.js +24 -0
- package/src/lib/axios/lib/helpers/isAbsoluteURL.js +14 -0
- package/src/lib/axios/lib/helpers/isURLSameOrigin.js +68 -0
- package/src/lib/axios/lib/helpers/normalizeHeaderName.js +12 -0
- package/src/lib/axios/lib/helpers/parseHeaders.js +53 -0
- package/src/lib/axios/lib/helpers/spread.js +27 -0
- package/src/lib/axios/lib/utils.js +303 -0
- package/src/lib/axios/modules/debug/CHANGELOG.md +395 -0
- package/src/lib/axios/modules/debug/LICENSE +19 -0
- package/src/lib/axios/modules/debug/README.md +437 -0
- package/src/lib/axios/modules/debug/dist/debug.js +886 -0
- package/src/lib/axios/modules/debug/node.js +1 -0
- package/src/lib/axios/modules/debug/package.json +96 -0
- package/src/lib/axios/modules/debug/src/browser.js +180 -0
- package/src/lib/axios/modules/debug/src/common.js +249 -0
- package/src/lib/axios/modules/debug/src/index.js +12 -0
- package/src/lib/axios/modules/debug/src/node.js +174 -0
- package/src/lib/axios/modules/follow-redirects/LICENSE +18 -0
- package/src/lib/axios/modules/follow-redirects/README.md +145 -0
- package/src/lib/axios/modules/follow-redirects/http.js +1 -0
- package/src/lib/axios/modules/follow-redirects/https.js +1 -0
- package/src/lib/axios/modules/follow-redirects/index.js +452 -0
- package/src/lib/axios/modules/follow-redirects/package.json +92 -0
- package/src/lib/axios/modules/is-buffer/LICENSE +21 -0
- package/src/lib/axios/modules/is-buffer/README.md +53 -0
- package/src/lib/axios/modules/is-buffer/index.js +21 -0
- package/src/lib/axios/modules/is-buffer/package.json +90 -0
- package/src/lib/axios/modules/is-buffer/test/basic.js +24 -0
- package/src/lib/axios/modules/ms/index.js +162 -0
- package/src/lib/axios/modules/ms/license.md +21 -0
- package/src/lib/axios/modules/ms/package.json +72 -0
- package/src/lib/axios/modules/ms/readme.md +60 -0
- package/src/lib/axios/package-lock.json +10437 -0
- package/src/lib/axios/package.json +111 -0
- package/src/lib/axios.min.js +10 -0
- package/src/lib/axiosRequest.js +84 -0
- package/src/lib/bmob.js +36 -0
- package/src/lib/common.js +227 -0
- package/src/lib/config.dev.js +62 -0
- package/src/lib/config.js +69 -0
- package/src/lib/dataType.js +17 -0
- package/src/lib/error.js +32 -0
- package/src/lib/file.js +250 -0
- package/src/lib/hapRequest.js +68 -0
- package/src/lib/hapStorage.js +62 -0
- package/src/lib/init.js +0 -0
- package/src/lib/nodestorage.js +14 -0
- package/src/lib/pay.js +19 -0
- package/src/lib/pointer.js +18 -0
- package/src/lib/query.js +689 -0
- package/src/lib/relation.js +45 -0
- package/src/lib/request.js +21 -0
- package/src/lib/sms.js +40 -0
- package/src/lib/socket.js +292 -0
- package/src/lib/storage.js +21 -0
- package/src/lib/user.js +225 -0
- package/src/lib/utf8md5.js +205 -0
- package/src/lib/utils.js +61 -0
- package/src/lib/webstorage.js +32 -0
- package/src/lib/wxRequest.js +88 -0
- package/src/lib/wxstorage.js +27 -0
- package/src/main.js +27 -0
- package/test/index.html +15 -0
- package/test/index.js +12 -0
- package/tsconfig.json +100 -0
@@ -0,0 +1,452 @@
|
|
1
|
+
var url = require("url");
|
2
|
+
var URL = url.URL;
|
3
|
+
var http = require("http");
|
4
|
+
var https = require("https");
|
5
|
+
var assert = require("assert");
|
6
|
+
var Writable = require("stream").Writable;
|
7
|
+
var debug = require("../debug")("follow-redirects");
|
8
|
+
|
9
|
+
// RFC7231§4.2.1: Of the request methods defined by this specification,
|
10
|
+
// the GET, HEAD, OPTIONS, and TRACE methods are defined to be safe.
|
11
|
+
var SAFE_METHODS = { GET: true, HEAD: true, OPTIONS: true, TRACE: true };
|
12
|
+
|
13
|
+
// Create handlers that pass events from native requests
|
14
|
+
var eventHandlers = Object.create(null);
|
15
|
+
["abort", "aborted", "connect", "error", "socket", "timeout"].forEach(function (event) {
|
16
|
+
eventHandlers[event] = function (arg1, arg2, arg3) {
|
17
|
+
this._redirectable.emit(event, arg1, arg2, arg3);
|
18
|
+
};
|
19
|
+
});
|
20
|
+
|
21
|
+
// An HTTP(S) request that can be redirected
|
22
|
+
function RedirectableRequest(options, responseCallback) {
|
23
|
+
// Initialize the request
|
24
|
+
Writable.call(this);
|
25
|
+
this._sanitizeOptions(options);
|
26
|
+
this._options = options;
|
27
|
+
this._ended = false;
|
28
|
+
this._ending = false;
|
29
|
+
this._redirectCount = 0;
|
30
|
+
this._redirects = [];
|
31
|
+
this._requestBodyLength = 0;
|
32
|
+
this._requestBodyBuffers = [];
|
33
|
+
|
34
|
+
// Attach a callback if passed
|
35
|
+
if (responseCallback) {
|
36
|
+
this.on("response", responseCallback);
|
37
|
+
}
|
38
|
+
|
39
|
+
// React to responses of native requests
|
40
|
+
var self = this;
|
41
|
+
this._onNativeResponse = function (response) {
|
42
|
+
self._processResponse(response);
|
43
|
+
};
|
44
|
+
|
45
|
+
// Perform the first request
|
46
|
+
this._performRequest();
|
47
|
+
}
|
48
|
+
RedirectableRequest.prototype = Object.create(Writable.prototype);
|
49
|
+
|
50
|
+
// Writes buffered data to the current native request
|
51
|
+
RedirectableRequest.prototype.write = function (data, encoding, callback) {
|
52
|
+
// Writing is not allowed if end has been called
|
53
|
+
if (this._ending) {
|
54
|
+
throw new Error("write after end");
|
55
|
+
}
|
56
|
+
|
57
|
+
// Validate input and shift parameters if necessary
|
58
|
+
if (!(typeof data === "string" || typeof data === "object" && ("length" in data))) {
|
59
|
+
throw new Error("data should be a string, Buffer or Uint8Array");
|
60
|
+
}
|
61
|
+
if (typeof encoding === "function") {
|
62
|
+
callback = encoding;
|
63
|
+
encoding = null;
|
64
|
+
}
|
65
|
+
|
66
|
+
// Ignore empty buffers, since writing them doesn't invoke the callback
|
67
|
+
// https://github.com/nodejs/node/issues/22066
|
68
|
+
if (data.length === 0) {
|
69
|
+
if (callback) {
|
70
|
+
callback();
|
71
|
+
}
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
// Only write when we don't exceed the maximum body length
|
75
|
+
if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
|
76
|
+
this._requestBodyLength += data.length;
|
77
|
+
this._requestBodyBuffers.push({ data: data, encoding: encoding });
|
78
|
+
this._currentRequest.write(data, encoding, callback);
|
79
|
+
}
|
80
|
+
// Error when we exceed the maximum body length
|
81
|
+
else {
|
82
|
+
this.emit("error", new Error("Request body larger than maxBodyLength limit"));
|
83
|
+
this.abort();
|
84
|
+
}
|
85
|
+
};
|
86
|
+
|
87
|
+
// Ends the current native request
|
88
|
+
RedirectableRequest.prototype.end = function (data, encoding, callback) {
|
89
|
+
// Shift parameters if necessary
|
90
|
+
if (typeof data === "function") {
|
91
|
+
callback = data;
|
92
|
+
data = encoding = null;
|
93
|
+
}
|
94
|
+
else if (typeof encoding === "function") {
|
95
|
+
callback = encoding;
|
96
|
+
encoding = null;
|
97
|
+
}
|
98
|
+
|
99
|
+
// Write data if needed and end
|
100
|
+
if (!data) {
|
101
|
+
this._ended = this._ending = true;
|
102
|
+
this._currentRequest.end(null, null, callback);
|
103
|
+
}
|
104
|
+
else {
|
105
|
+
var self = this;
|
106
|
+
var currentRequest = this._currentRequest;
|
107
|
+
this.write(data, encoding, function () {
|
108
|
+
self._ended = true;
|
109
|
+
currentRequest.end(null, null, callback);
|
110
|
+
});
|
111
|
+
this._ending = true;
|
112
|
+
}
|
113
|
+
};
|
114
|
+
|
115
|
+
// Sets a header value on the current native request
|
116
|
+
RedirectableRequest.prototype.setHeader = function (name, value) {
|
117
|
+
this._options.headers[name] = value;
|
118
|
+
this._currentRequest.setHeader(name, value);
|
119
|
+
};
|
120
|
+
|
121
|
+
// Clears a header value on the current native request
|
122
|
+
RedirectableRequest.prototype.removeHeader = function (name) {
|
123
|
+
delete this._options.headers[name];
|
124
|
+
this._currentRequest.removeHeader(name);
|
125
|
+
};
|
126
|
+
|
127
|
+
// Global timeout for all underlying requests
|
128
|
+
RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
|
129
|
+
if (callback) {
|
130
|
+
this.once("timeout", callback);
|
131
|
+
}
|
132
|
+
|
133
|
+
if (this.socket) {
|
134
|
+
startTimer(this, msecs);
|
135
|
+
}
|
136
|
+
else {
|
137
|
+
var self = this;
|
138
|
+
this._currentRequest.once("socket", function () {
|
139
|
+
startTimer(self, msecs);
|
140
|
+
});
|
141
|
+
}
|
142
|
+
|
143
|
+
this.once("response", clearTimer);
|
144
|
+
this.once("error", clearTimer);
|
145
|
+
|
146
|
+
return this;
|
147
|
+
};
|
148
|
+
|
149
|
+
function startTimer(request, msecs) {
|
150
|
+
clearTimeout(request._timeout);
|
151
|
+
request._timeout = setTimeout(function () {
|
152
|
+
request.emit("timeout");
|
153
|
+
}, msecs);
|
154
|
+
}
|
155
|
+
|
156
|
+
function clearTimer() {
|
157
|
+
clearTimeout(this._timeout);
|
158
|
+
}
|
159
|
+
|
160
|
+
// Proxy all other public ClientRequest methods
|
161
|
+
[
|
162
|
+
"abort", "flushHeaders", "getHeader",
|
163
|
+
"setNoDelay", "setSocketKeepAlive",
|
164
|
+
].forEach(function (method) {
|
165
|
+
RedirectableRequest.prototype[method] = function (a, b) {
|
166
|
+
return this._currentRequest[method](a, b);
|
167
|
+
};
|
168
|
+
});
|
169
|
+
|
170
|
+
// Proxy all public ClientRequest properties
|
171
|
+
["aborted", "connection", "socket"].forEach(function (property) {
|
172
|
+
Object.defineProperty(RedirectableRequest.prototype, property, {
|
173
|
+
get: function () { return this._currentRequest[property]; },
|
174
|
+
});
|
175
|
+
});
|
176
|
+
|
177
|
+
RedirectableRequest.prototype._sanitizeOptions = function (options) {
|
178
|
+
// Ensure headers are always present
|
179
|
+
if (!options.headers) {
|
180
|
+
options.headers = {};
|
181
|
+
}
|
182
|
+
|
183
|
+
// Since http.request treats host as an alias of hostname,
|
184
|
+
// but the url module interprets host as hostname plus port,
|
185
|
+
// eliminate the host property to avoid confusion.
|
186
|
+
if (options.host) {
|
187
|
+
// Use hostname if set, because it has precedence
|
188
|
+
if (!options.hostname) {
|
189
|
+
options.hostname = options.host;
|
190
|
+
}
|
191
|
+
delete options.host;
|
192
|
+
}
|
193
|
+
|
194
|
+
// Complete the URL object when necessary
|
195
|
+
if (!options.pathname && options.path) {
|
196
|
+
var searchPos = options.path.indexOf("?");
|
197
|
+
if (searchPos < 0) {
|
198
|
+
options.pathname = options.path;
|
199
|
+
}
|
200
|
+
else {
|
201
|
+
options.pathname = options.path.substring(0, searchPos);
|
202
|
+
options.search = options.path.substring(searchPos);
|
203
|
+
}
|
204
|
+
}
|
205
|
+
};
|
206
|
+
|
207
|
+
|
208
|
+
// Executes the next native request (initial or redirect)
|
209
|
+
RedirectableRequest.prototype._performRequest = function () {
|
210
|
+
// Load the native protocol
|
211
|
+
var protocol = this._options.protocol;
|
212
|
+
var nativeProtocol = this._options.nativeProtocols[protocol];
|
213
|
+
if (!nativeProtocol) {
|
214
|
+
this.emit("error", new Error("Unsupported protocol " + protocol));
|
215
|
+
return;
|
216
|
+
}
|
217
|
+
|
218
|
+
// If specified, use the agent corresponding to the protocol
|
219
|
+
// (HTTP and HTTPS use different types of agents)
|
220
|
+
if (this._options.agents) {
|
221
|
+
var scheme = protocol.substr(0, protocol.length - 1);
|
222
|
+
this._options.agent = this._options.agents[scheme];
|
223
|
+
}
|
224
|
+
|
225
|
+
// Create the native request
|
226
|
+
var request = this._currentRequest =
|
227
|
+
nativeProtocol.request(this._options, this._onNativeResponse);
|
228
|
+
this._currentUrl = url.format(this._options);
|
229
|
+
|
230
|
+
// Set up event handlers
|
231
|
+
request._redirectable = this;
|
232
|
+
for (var event in eventHandlers) {
|
233
|
+
/* istanbul ignore else */
|
234
|
+
if (event) {
|
235
|
+
request.on(event, eventHandlers[event]);
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
239
|
+
// End a redirected request
|
240
|
+
// (The first request must be ended explicitly with RedirectableRequest#end)
|
241
|
+
if (this._isRedirect) {
|
242
|
+
// Write the request entity and end.
|
243
|
+
var i = 0;
|
244
|
+
var self = this;
|
245
|
+
var buffers = this._requestBodyBuffers;
|
246
|
+
(function writeNext(error) {
|
247
|
+
// Only write if this request has not been redirected yet
|
248
|
+
/* istanbul ignore else */
|
249
|
+
if (request === self._currentRequest) {
|
250
|
+
// Report any write errors
|
251
|
+
/* istanbul ignore if */
|
252
|
+
if (error) {
|
253
|
+
self.emit("error", error);
|
254
|
+
}
|
255
|
+
// Write the next buffer if there are still left
|
256
|
+
else if (i < buffers.length) {
|
257
|
+
var buffer = buffers[i++];
|
258
|
+
/* istanbul ignore else */
|
259
|
+
if (!request.finished) {
|
260
|
+
request.write(buffer.data, buffer.encoding, writeNext);
|
261
|
+
}
|
262
|
+
}
|
263
|
+
// End the request if `end` has been called on us
|
264
|
+
else if (self._ended) {
|
265
|
+
request.end();
|
266
|
+
}
|
267
|
+
}
|
268
|
+
}());
|
269
|
+
}
|
270
|
+
};
|
271
|
+
|
272
|
+
// Processes a response from the current native request
|
273
|
+
RedirectableRequest.prototype._processResponse = function (response) {
|
274
|
+
// Store the redirected response
|
275
|
+
var statusCode = response.statusCode;
|
276
|
+
if (this._options.trackRedirects) {
|
277
|
+
this._redirects.push({
|
278
|
+
url: this._currentUrl,
|
279
|
+
headers: response.headers,
|
280
|
+
statusCode: statusCode,
|
281
|
+
});
|
282
|
+
}
|
283
|
+
|
284
|
+
// RFC7231§6.4: The 3xx (Redirection) class of status code indicates
|
285
|
+
// that further action needs to be taken by the user agent in order to
|
286
|
+
// fulfill the request. If a Location header field is provided,
|
287
|
+
// the user agent MAY automatically redirect its request to the URI
|
288
|
+
// referenced by the Location field value,
|
289
|
+
// even if the specific status code is not understood.
|
290
|
+
var location = response.headers.location;
|
291
|
+
if (location && this._options.followRedirects !== false &&
|
292
|
+
statusCode >= 300 && statusCode < 400) {
|
293
|
+
// Abort the current request
|
294
|
+
this._currentRequest.removeAllListeners();
|
295
|
+
this._currentRequest.on("error", noop);
|
296
|
+
this._currentRequest.abort();
|
297
|
+
// Discard the remainder of the response to avoid waiting for data
|
298
|
+
response.destroy();
|
299
|
+
|
300
|
+
// RFC7231§6.4: A client SHOULD detect and intervene
|
301
|
+
// in cyclical redirections (i.e., "infinite" redirection loops).
|
302
|
+
if (++this._redirectCount > this._options.maxRedirects) {
|
303
|
+
this.emit("error", new Error("Max redirects exceeded."));
|
304
|
+
return;
|
305
|
+
}
|
306
|
+
|
307
|
+
// RFC7231§6.4: Automatic redirection needs to done with
|
308
|
+
// care for methods not known to be safe […],
|
309
|
+
// since the user might not wish to redirect an unsafe request.
|
310
|
+
// RFC7231§6.4.7: The 307 (Temporary Redirect) status code indicates
|
311
|
+
// that the target resource resides temporarily under a different URI
|
312
|
+
// and the user agent MUST NOT change the request method
|
313
|
+
// if it performs an automatic redirection to that URI.
|
314
|
+
var header;
|
315
|
+
var headers = this._options.headers;
|
316
|
+
if (statusCode !== 307 && !(this._options.method in SAFE_METHODS)) {
|
317
|
+
this._options.method = "GET";
|
318
|
+
// Drop a possible entity and headers related to it
|
319
|
+
this._requestBodyBuffers = [];
|
320
|
+
for (header in headers) {
|
321
|
+
if (/^content-/i.test(header)) {
|
322
|
+
delete headers[header];
|
323
|
+
}
|
324
|
+
}
|
325
|
+
}
|
326
|
+
|
327
|
+
// Drop the Host header, as the redirect might lead to a different host
|
328
|
+
if (!this._isRedirect) {
|
329
|
+
for (header in headers) {
|
330
|
+
if (/^host$/i.test(header)) {
|
331
|
+
delete headers[header];
|
332
|
+
}
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
// Perform the redirected request
|
337
|
+
var redirectUrl = url.resolve(this._currentUrl, location);
|
338
|
+
debug("redirecting to", redirectUrl);
|
339
|
+
Object.assign(this._options, url.parse(redirectUrl));
|
340
|
+
if (typeof this._options.beforeRedirect === "function") {
|
341
|
+
try {
|
342
|
+
this._options.beforeRedirect.call(null, this._options);
|
343
|
+
}
|
344
|
+
catch (err) {
|
345
|
+
this.emit("error", err);
|
346
|
+
return;
|
347
|
+
}
|
348
|
+
this._sanitizeOptions(this._options);
|
349
|
+
}
|
350
|
+
this._isRedirect = true;
|
351
|
+
this._performRequest();
|
352
|
+
}
|
353
|
+
else {
|
354
|
+
// The response is not a redirect; return it as-is
|
355
|
+
response.responseUrl = this._currentUrl;
|
356
|
+
response.redirects = this._redirects;
|
357
|
+
this.emit("response", response);
|
358
|
+
|
359
|
+
// Clean up
|
360
|
+
this._requestBodyBuffers = [];
|
361
|
+
}
|
362
|
+
};
|
363
|
+
|
364
|
+
// Wraps the key/value object of protocols with redirect functionality
|
365
|
+
function wrap(protocols) {
|
366
|
+
// Default settings
|
367
|
+
var exports = {
|
368
|
+
maxRedirects: 21,
|
369
|
+
maxBodyLength: 10 * 1024 * 1024,
|
370
|
+
};
|
371
|
+
|
372
|
+
// Wrap each protocol
|
373
|
+
var nativeProtocols = {};
|
374
|
+
Object.keys(protocols).forEach(function (scheme) {
|
375
|
+
var protocol = scheme + ":";
|
376
|
+
var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
|
377
|
+
var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
|
378
|
+
|
379
|
+
// Executes a request, following redirects
|
380
|
+
wrappedProtocol.request = function (input, options, callback) {
|
381
|
+
// Parse parameters
|
382
|
+
if (typeof input === "string") {
|
383
|
+
var urlStr = input;
|
384
|
+
try {
|
385
|
+
input = urlToOptions(new URL(urlStr));
|
386
|
+
}
|
387
|
+
catch (err) {
|
388
|
+
/* istanbul ignore next */
|
389
|
+
input = url.parse(urlStr);
|
390
|
+
}
|
391
|
+
}
|
392
|
+
else if (URL && (input instanceof URL)) {
|
393
|
+
input = urlToOptions(input);
|
394
|
+
}
|
395
|
+
else {
|
396
|
+
callback = options;
|
397
|
+
options = input;
|
398
|
+
input = { protocol: protocol };
|
399
|
+
}
|
400
|
+
if (typeof options === "function") {
|
401
|
+
callback = options;
|
402
|
+
options = null;
|
403
|
+
}
|
404
|
+
|
405
|
+
// Set defaults
|
406
|
+
options = Object.assign({
|
407
|
+
maxRedirects: exports.maxRedirects,
|
408
|
+
maxBodyLength: exports.maxBodyLength,
|
409
|
+
}, input, options);
|
410
|
+
options.nativeProtocols = nativeProtocols;
|
411
|
+
|
412
|
+
assert.equal(options.protocol, protocol, "protocol mismatch");
|
413
|
+
debug("options", options);
|
414
|
+
return new RedirectableRequest(options, callback);
|
415
|
+
};
|
416
|
+
|
417
|
+
// Executes a GET request, following redirects
|
418
|
+
wrappedProtocol.get = function (input, options, callback) {
|
419
|
+
var request = wrappedProtocol.request(input, options, callback);
|
420
|
+
request.end();
|
421
|
+
return request;
|
422
|
+
};
|
423
|
+
});
|
424
|
+
return exports;
|
425
|
+
}
|
426
|
+
|
427
|
+
/* istanbul ignore next */
|
428
|
+
function noop() { /* empty */ }
|
429
|
+
|
430
|
+
// from https://github.com/nodejs/node/blob/master/lib/internal/url.js
|
431
|
+
function urlToOptions(urlObject) {
|
432
|
+
var options = {
|
433
|
+
protocol: urlObject.protocol,
|
434
|
+
hostname: urlObject.hostname.startsWith("[") ?
|
435
|
+
/* istanbul ignore next */
|
436
|
+
urlObject.hostname.slice(1, -1) :
|
437
|
+
urlObject.hostname,
|
438
|
+
hash: urlObject.hash,
|
439
|
+
search: urlObject.search,
|
440
|
+
pathname: urlObject.pathname,
|
441
|
+
path: urlObject.pathname + urlObject.search,
|
442
|
+
href: urlObject.href,
|
443
|
+
};
|
444
|
+
if (urlObject.port !== "") {
|
445
|
+
options.port = Number(urlObject.port);
|
446
|
+
}
|
447
|
+
return options;
|
448
|
+
}
|
449
|
+
|
450
|
+
// Exports
|
451
|
+
module.exports = wrap({ http: http, https: https });
|
452
|
+
module.exports.wrap = wrap;
|
@@ -0,0 +1,92 @@
|
|
1
|
+
{
|
2
|
+
"_args": [
|
3
|
+
[
|
4
|
+
"follow-redirects@1.9.0",
|
5
|
+
"F:\\项目\\hydrogen-js-sdk\\src\\lib\\axios"
|
6
|
+
]
|
7
|
+
],
|
8
|
+
"_from": "follow-redirects@1.9.0",
|
9
|
+
"_id": "follow-redirects@1.9.0",
|
10
|
+
"_inBundle": false,
|
11
|
+
"_integrity": "sha512-CRcPzsSIbXyVDl0QI01muNDu69S8trU4jArW9LpOt2WtC6LyUJetcIrmfHsRBx7/Jb6GHJUiuqyYxPooFfNt6A==",
|
12
|
+
"_location": "/follow-redirects",
|
13
|
+
"_phantomChildren": {},
|
14
|
+
"_requested": {
|
15
|
+
"type": "version",
|
16
|
+
"registry": true,
|
17
|
+
"raw": "follow-redirects@1.9.0",
|
18
|
+
"name": "follow-redirects",
|
19
|
+
"escapedName": "follow-redirects",
|
20
|
+
"rawSpec": "1.9.0",
|
21
|
+
"saveSpec": null,
|
22
|
+
"fetchSpec": "1.9.0"
|
23
|
+
},
|
24
|
+
"_requiredBy": [
|
25
|
+
"/",
|
26
|
+
"/axios",
|
27
|
+
"/http-proxy"
|
28
|
+
],
|
29
|
+
"_resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.9.0.tgz",
|
30
|
+
"_spec": "1.9.0",
|
31
|
+
"_where": "F:\\项目\\hydrogen-js-sdk\\src\\lib\\axios",
|
32
|
+
"author": {
|
33
|
+
"name": "Ruben Verborgh",
|
34
|
+
"email": "ruben@verborgh.org",
|
35
|
+
"url": "https://ruben.verborgh.org/"
|
36
|
+
},
|
37
|
+
"bugs": {
|
38
|
+
"url": "https://github.com/follow-redirects/follow-redirects/issues"
|
39
|
+
},
|
40
|
+
"contributors": [
|
41
|
+
{
|
42
|
+
"name": "Olivier Lalonde",
|
43
|
+
"email": "olalonde@gmail.com",
|
44
|
+
"url": "http://www.syskall.com"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"name": "James Talmage",
|
48
|
+
"email": "james@talmage.io"
|
49
|
+
}
|
50
|
+
],
|
51
|
+
"dependencies": {
|
52
|
+
"debug": "^3.0.0"
|
53
|
+
},
|
54
|
+
"description": "HTTP and HTTPS modules that follow redirects.",
|
55
|
+
"devDependencies": {
|
56
|
+
"concat-stream": "^2.0.0",
|
57
|
+
"eslint": "^5.16.0",
|
58
|
+
"express": "^4.16.4",
|
59
|
+
"lolex": "^3.1.0",
|
60
|
+
"mocha": "^6.0.2",
|
61
|
+
"nyc": "^14.1.1"
|
62
|
+
},
|
63
|
+
"engines": {
|
64
|
+
"node": ">=4.0"
|
65
|
+
},
|
66
|
+
"files": [
|
67
|
+
"*.js"
|
68
|
+
],
|
69
|
+
"homepage": "https://github.com/follow-redirects/follow-redirects",
|
70
|
+
"keywords": [
|
71
|
+
"http",
|
72
|
+
"https",
|
73
|
+
"url",
|
74
|
+
"redirect",
|
75
|
+
"client",
|
76
|
+
"location",
|
77
|
+
"utility"
|
78
|
+
],
|
79
|
+
"license": "MIT",
|
80
|
+
"main": "index.js",
|
81
|
+
"name": "follow-redirects",
|
82
|
+
"repository": {
|
83
|
+
"type": "git",
|
84
|
+
"url": "git+ssh://git@github.com/follow-redirects/follow-redirects.git"
|
85
|
+
},
|
86
|
+
"scripts": {
|
87
|
+
"lint": "eslint *.js test",
|
88
|
+
"mocha": "nyc mocha",
|
89
|
+
"test": "npm run lint && npm run mocha"
|
90
|
+
},
|
91
|
+
"version": "1.9.0"
|
92
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) Feross Aboukhadijeh
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# is-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
|
2
|
+
|
3
|
+
[travis-image]: https://img.shields.io/travis/feross/is-buffer/master.svg
|
4
|
+
[travis-url]: https://travis-ci.org/feross/is-buffer
|
5
|
+
[npm-image]: https://img.shields.io/npm/v/is-buffer.svg
|
6
|
+
[npm-url]: https://npmjs.org/package/is-buffer
|
7
|
+
[downloads-image]: https://img.shields.io/npm/dm/is-buffer.svg
|
8
|
+
[downloads-url]: https://npmjs.org/package/is-buffer
|
9
|
+
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
|
10
|
+
[standard-url]: https://standardjs.com
|
11
|
+
|
12
|
+
#### Determine if an object is a [`Buffer`](http://nodejs.org/api/buffer.html) (including the [browserify Buffer](https://github.com/feross/buffer))
|
13
|
+
|
14
|
+
[![saucelabs][saucelabs-image]][saucelabs-url]
|
15
|
+
|
16
|
+
[saucelabs-image]: https://saucelabs.com/browser-matrix/is-buffer.svg
|
17
|
+
[saucelabs-url]: https://saucelabs.com/u/is-buffer
|
18
|
+
|
19
|
+
## Why not use `Buffer.isBuffer`?
|
20
|
+
|
21
|
+
This module lets you check if an object is a `Buffer` without using `Buffer.isBuffer` (which includes the whole [buffer](https://github.com/feross/buffer) module in [browserify](http://browserify.org/)).
|
22
|
+
|
23
|
+
It's future-proof and works in node too!
|
24
|
+
|
25
|
+
## install
|
26
|
+
|
27
|
+
```bash
|
28
|
+
npm install is-buffer
|
29
|
+
```
|
30
|
+
|
31
|
+
## usage
|
32
|
+
|
33
|
+
```js
|
34
|
+
var isBuffer = require('is-buffer')
|
35
|
+
|
36
|
+
isBuffer(new Buffer(4)) // true
|
37
|
+
|
38
|
+
isBuffer(undefined) // false
|
39
|
+
isBuffer(null) // false
|
40
|
+
isBuffer('') // false
|
41
|
+
isBuffer(true) // false
|
42
|
+
isBuffer(false) // false
|
43
|
+
isBuffer(0) // false
|
44
|
+
isBuffer(1) // false
|
45
|
+
isBuffer(1.0) // false
|
46
|
+
isBuffer('string') // false
|
47
|
+
isBuffer({}) // false
|
48
|
+
isBuffer(function foo () {}) // false
|
49
|
+
```
|
50
|
+
|
51
|
+
## license
|
52
|
+
|
53
|
+
MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org).
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/*!
|
2
|
+
* Determine if an object is a Buffer
|
3
|
+
*
|
4
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
5
|
+
* @license MIT
|
6
|
+
*/
|
7
|
+
|
8
|
+
// The _isBuffer check is for Safari 5-7 support, because it's missing
|
9
|
+
// Object.prototype.constructor. Remove this eventually
|
10
|
+
module.exports = function (obj) {
|
11
|
+
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
|
12
|
+
}
|
13
|
+
|
14
|
+
function isBuffer (obj) {
|
15
|
+
return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
|
16
|
+
}
|
17
|
+
|
18
|
+
// For Node v0.10 support. Remove this eventually.
|
19
|
+
function isSlowBuffer (obj) {
|
20
|
+
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
|
21
|
+
}
|