superagent 8.0.4 → 8.0.5
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/README.md +12 -12
- package/dist/superagent.js +2 -163
- package/lib/node/http2wrapper.js +4 -2
- package/lib/node/index.js +3 -3
- package/lib/request-base.js +3 -3
- package/package.json +5 -5
package/dist/superagent.js
CHANGED
|
@@ -58,30 +58,24 @@ if ($defineProperty) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
},{"function-bind":7,"get-intrinsic":8}],4:[function(require,module,exports){
|
|
61
|
-
|
|
62
|
-
|
|
63
61
|
if (typeof module !== 'undefined') {
|
|
64
62
|
module.exports = Emitter;
|
|
65
63
|
}
|
|
66
|
-
|
|
67
64
|
function Emitter(obj) {
|
|
68
65
|
if (obj) return mixin(obj);
|
|
69
66
|
}
|
|
70
67
|
;
|
|
71
|
-
|
|
72
68
|
function mixin(obj) {
|
|
73
69
|
for (var key in Emitter.prototype) {
|
|
74
70
|
obj[key] = Emitter.prototype[key];
|
|
75
71
|
}
|
|
76
72
|
return obj;
|
|
77
73
|
}
|
|
78
|
-
|
|
79
74
|
Emitter.prototype.on = Emitter.prototype.addEventListener = function (event, fn) {
|
|
80
75
|
this._callbacks = this._callbacks || {};
|
|
81
76
|
(this._callbacks['$' + event] = this._callbacks['$' + event] || []).push(fn);
|
|
82
77
|
return this;
|
|
83
78
|
};
|
|
84
|
-
|
|
85
79
|
Emitter.prototype.once = function (event, fn) {
|
|
86
80
|
function on() {
|
|
87
81
|
this.off(event, on);
|
|
@@ -91,23 +85,18 @@ Emitter.prototype.once = function (event, fn) {
|
|
|
91
85
|
this.on(event, on);
|
|
92
86
|
return this;
|
|
93
87
|
};
|
|
94
|
-
|
|
95
88
|
Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function (event, fn) {
|
|
96
89
|
this._callbacks = this._callbacks || {};
|
|
97
|
-
|
|
98
90
|
if (0 == arguments.length) {
|
|
99
91
|
this._callbacks = {};
|
|
100
92
|
return this;
|
|
101
93
|
}
|
|
102
|
-
|
|
103
94
|
var callbacks = this._callbacks['$' + event];
|
|
104
95
|
if (!callbacks) return this;
|
|
105
|
-
|
|
106
96
|
if (1 == arguments.length) {
|
|
107
97
|
delete this._callbacks['$' + event];
|
|
108
98
|
return this;
|
|
109
99
|
}
|
|
110
|
-
|
|
111
100
|
var cb;
|
|
112
101
|
for (var i = 0; i < callbacks.length; i++) {
|
|
113
102
|
cb = callbacks[i];
|
|
@@ -116,13 +105,11 @@ Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.rem
|
|
|
116
105
|
break;
|
|
117
106
|
}
|
|
118
107
|
}
|
|
119
|
-
|
|
120
108
|
if (callbacks.length === 0) {
|
|
121
109
|
delete this._callbacks['$' + event];
|
|
122
110
|
}
|
|
123
111
|
return this;
|
|
124
112
|
};
|
|
125
|
-
|
|
126
113
|
Emitter.prototype.emit = function (event) {
|
|
127
114
|
this._callbacks = this._callbacks || {};
|
|
128
115
|
var args = new Array(arguments.length - 1),
|
|
@@ -138,12 +125,10 @@ Emitter.prototype.emit = function (event) {
|
|
|
138
125
|
}
|
|
139
126
|
return this;
|
|
140
127
|
};
|
|
141
|
-
|
|
142
128
|
Emitter.prototype.listeners = function (event) {
|
|
143
129
|
this._callbacks = this._callbacks || {};
|
|
144
130
|
return this._callbacks['$' + event] || [];
|
|
145
131
|
};
|
|
146
|
-
|
|
147
132
|
Emitter.prototype.hasListeners = function (event) {
|
|
148
133
|
return !!this.listeners(event).length;
|
|
149
134
|
};
|
|
@@ -163,7 +148,6 @@ function defaultOptions() {
|
|
|
163
148
|
edgesLimit: Number.MAX_SAFE_INTEGER
|
|
164
149
|
};
|
|
165
150
|
}
|
|
166
|
-
|
|
167
151
|
function stringify(obj, replacer, spacer, options) {
|
|
168
152
|
if (typeof options === 'undefined') {
|
|
169
153
|
options = defaultOptions();
|
|
@@ -239,7 +223,6 @@ function decirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
239
223
|
stack.pop();
|
|
240
224
|
}
|
|
241
225
|
}
|
|
242
|
-
|
|
243
226
|
function compareFunction(a, b) {
|
|
244
227
|
if (a < b) {
|
|
245
228
|
return -1;
|
|
@@ -323,7 +306,6 @@ function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
323
306
|
stack.pop();
|
|
324
307
|
}
|
|
325
308
|
}
|
|
326
|
-
|
|
327
309
|
function replaceGetterValues(replacer) {
|
|
328
310
|
replacer = typeof replacer !== 'undefined' ? replacer : function (k, v) {
|
|
329
311
|
return v;
|
|
@@ -345,7 +327,6 @@ function replaceGetterValues(replacer) {
|
|
|
345
327
|
|
|
346
328
|
},{}],6:[function(require,module,exports){
|
|
347
329
|
'use strict';
|
|
348
|
-
|
|
349
330
|
var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
|
|
350
331
|
var slice = Array.prototype.slice;
|
|
351
332
|
var toStr = Object.prototype.toString;
|
|
@@ -396,7 +377,6 @@ var undefined;
|
|
|
396
377
|
var $SyntaxError = SyntaxError;
|
|
397
378
|
var $Function = Function;
|
|
398
379
|
var $TypeError = TypeError;
|
|
399
|
-
|
|
400
380
|
var getEvalledConstructor = function (expressionSyntax) {
|
|
401
381
|
try {
|
|
402
382
|
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
@@ -410,7 +390,6 @@ if ($gOPD) {
|
|
|
410
390
|
$gOPD = null;
|
|
411
391
|
}
|
|
412
392
|
}
|
|
413
|
-
|
|
414
393
|
var throwTypeError = function () {
|
|
415
394
|
throw new $TypeError();
|
|
416
395
|
};
|
|
@@ -430,7 +409,6 @@ var hasSymbols = require('has-symbols')();
|
|
|
430
409
|
var getProto = Object.getPrototypeOf || function (x) {
|
|
431
410
|
return x.__proto__;
|
|
432
411
|
};
|
|
433
|
-
|
|
434
412
|
var needsEval = {};
|
|
435
413
|
var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
|
|
436
414
|
var INTRINSICS = {
|
|
@@ -581,7 +559,6 @@ var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
|
|
|
581
559
|
var $replace = bind.call(Function.call, String.prototype.replace);
|
|
582
560
|
var $strSlice = bind.call(Function.call, String.prototype.slice);
|
|
583
561
|
var $exec = bind.call(Function.call, RegExp.prototype.exec);
|
|
584
|
-
|
|
585
562
|
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
586
563
|
var reEscapeChar = /\\(\\)?/g;
|
|
587
564
|
var stringToPath = function stringToPath(string) {
|
|
@@ -598,7 +575,6 @@ var stringToPath = function stringToPath(string) {
|
|
|
598
575
|
});
|
|
599
576
|
return result;
|
|
600
577
|
};
|
|
601
|
-
|
|
602
578
|
var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
|
603
579
|
var intrinsicName = name;
|
|
604
580
|
var alias;
|
|
@@ -667,7 +643,6 @@ module.exports = function GetIntrinsic(name, allowMissing) {
|
|
|
667
643
|
if ($gOPD && i + 1 >= parts.length) {
|
|
668
644
|
var desc = $gOPD(value, part);
|
|
669
645
|
isOwn = !!desc;
|
|
670
|
-
|
|
671
646
|
if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
|
|
672
647
|
value = desc.get;
|
|
673
648
|
} else {
|
|
@@ -708,7 +683,6 @@ module.exports = function hasNativeSymbols() {
|
|
|
708
683
|
|
|
709
684
|
},{"./shams":10}],10:[function(require,module,exports){
|
|
710
685
|
'use strict';
|
|
711
|
-
|
|
712
686
|
module.exports = function hasSymbols() {
|
|
713
687
|
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') {
|
|
714
688
|
return false;
|
|
@@ -728,7 +702,6 @@ module.exports = function hasSymbols() {
|
|
|
728
702
|
if (Object.prototype.toString.call(symObj) !== '[object Symbol]') {
|
|
729
703
|
return false;
|
|
730
704
|
}
|
|
731
|
-
|
|
732
705
|
var symVal = 42;
|
|
733
706
|
obj[sym] = symVal;
|
|
734
707
|
for (sym in obj) {
|
|
@@ -1019,7 +992,6 @@ function isNumber(obj) {
|
|
|
1019
992
|
function isBoolean(obj) {
|
|
1020
993
|
return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1021
994
|
}
|
|
1022
|
-
|
|
1023
995
|
function isSymbol(obj) {
|
|
1024
996
|
if (hasShammedSymbols) {
|
|
1025
997
|
return obj && typeof obj === 'object' && obj instanceof Symbol;
|
|
@@ -1260,9 +1232,7 @@ function arrObjKeys(obj, inspect) {
|
|
|
1260
1232
|
}
|
|
1261
1233
|
|
|
1262
1234
|
},{"./util.inspect":1}],13:[function(require,module,exports){
|
|
1263
|
-
|
|
1264
1235
|
var process = module.exports = {};
|
|
1265
|
-
|
|
1266
1236
|
var cachedSetTimeout;
|
|
1267
1237
|
var cachedClearTimeout;
|
|
1268
1238
|
function defaultSetTimout() {
|
|
@@ -1379,7 +1349,6 @@ process.nextTick = function (fun) {
|
|
|
1379
1349
|
runTimeout(drainQueue);
|
|
1380
1350
|
}
|
|
1381
1351
|
};
|
|
1382
|
-
|
|
1383
1352
|
function Item(fun, array) {
|
|
1384
1353
|
this.fun = fun;
|
|
1385
1354
|
this.array = array;
|
|
@@ -1489,11 +1458,8 @@ var parseArrayValue = function (val, options) {
|
|
|
1489
1458
|
}
|
|
1490
1459
|
return val;
|
|
1491
1460
|
};
|
|
1492
|
-
|
|
1493
1461
|
var isoSentinel = 'utf8=%26%2310003%3B';
|
|
1494
|
-
|
|
1495
1462
|
var charsetSentinel = 'utf8=%E2%9C%93';
|
|
1496
|
-
|
|
1497
1463
|
var parseValues = function parseQueryStringValues(str, options) {
|
|
1498
1464
|
var obj = {};
|
|
1499
1465
|
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
|
|
@@ -1515,7 +1481,6 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
1515
1481
|
}
|
|
1516
1482
|
}
|
|
1517
1483
|
}
|
|
1518
|
-
|
|
1519
1484
|
for (i = 0; i < parts.length; ++i) {
|
|
1520
1485
|
if (i === skipIndex) {
|
|
1521
1486
|
continue;
|
|
@@ -1577,15 +1542,11 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesPars
|
|
|
1577
1542
|
if (!givenKey) {
|
|
1578
1543
|
return;
|
|
1579
1544
|
}
|
|
1580
|
-
|
|
1581
1545
|
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
|
|
1582
|
-
|
|
1583
1546
|
var brackets = /(\[[^[\]]*])/;
|
|
1584
1547
|
var child = /(\[[^[\]]*])/g;
|
|
1585
|
-
|
|
1586
1548
|
var segment = options.depth > 0 && brackets.exec(key);
|
|
1587
1549
|
var parent = segment ? key.slice(0, segment.index) : key;
|
|
1588
|
-
|
|
1589
1550
|
var keys = [];
|
|
1590
1551
|
if (parent) {
|
|
1591
1552
|
if (!options.plainObjects && has.call(Object.prototype, parent)) {
|
|
@@ -1595,7 +1556,6 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesPars
|
|
|
1595
1556
|
}
|
|
1596
1557
|
keys.push(parent);
|
|
1597
1558
|
}
|
|
1598
|
-
|
|
1599
1559
|
var i = 0;
|
|
1600
1560
|
while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
|
|
1601
1561
|
i += 1;
|
|
@@ -1606,7 +1566,6 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesPars
|
|
|
1606
1566
|
}
|
|
1607
1567
|
keys.push(segment[1]);
|
|
1608
1568
|
}
|
|
1609
|
-
|
|
1610
1569
|
if (segment) {
|
|
1611
1570
|
keys.push('[' + key.slice(segment.index) + ']');
|
|
1612
1571
|
}
|
|
@@ -1649,7 +1608,6 @@ module.exports = function (str, opts) {
|
|
|
1649
1608
|
}
|
|
1650
1609
|
var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
|
|
1651
1610
|
var obj = options.plainObjects ? Object.create(null) : {};
|
|
1652
|
-
|
|
1653
1611
|
var keys = Object.keys(tempObj);
|
|
1654
1612
|
for (var i = 0; i < keys.length; ++i) {
|
|
1655
1613
|
var key = keys[i];
|
|
@@ -1726,7 +1684,6 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, commaRou
|
|
|
1726
1684
|
findFlag = true;
|
|
1727
1685
|
}
|
|
1728
1686
|
}
|
|
1729
|
-
|
|
1730
1687
|
if (typeof tmpSc.get(sentinel) === 'undefined') {
|
|
1731
1688
|
step = 0;
|
|
1732
1689
|
}
|
|
@@ -2109,7 +2066,6 @@ var $weakMapHas = callBound('WeakMap.prototype.has', true);
|
|
|
2109
2066
|
var $mapGet = callBound('Map.prototype.get', true);
|
|
2110
2067
|
var $mapSet = callBound('Map.prototype.set', true);
|
|
2111
2068
|
var $mapHas = callBound('Map.prototype.has', true);
|
|
2112
|
-
|
|
2113
2069
|
var listGetNode = function (list, key) {
|
|
2114
2070
|
for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
|
|
2115
2071
|
if (curr.key === key) {
|
|
@@ -2229,8 +2185,6 @@ Agent.prototype._setDefaults = function (request) {
|
|
|
2229
2185
|
module.exports = Agent;
|
|
2230
2186
|
|
|
2231
2187
|
},{}],21:[function(require,module,exports){
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
2188
|
let root;
|
|
2235
2189
|
if (typeof window !== 'undefined') {
|
|
2236
2190
|
root = window;
|
|
@@ -2251,14 +2205,11 @@ const {
|
|
|
2251
2205
|
} = require('./utils');
|
|
2252
2206
|
const ResponseBase = require('./response-base');
|
|
2253
2207
|
const Agent = require('./agent-base');
|
|
2254
|
-
|
|
2255
2208
|
function noop() {}
|
|
2256
|
-
|
|
2257
2209
|
module.exports = function (method, url) {
|
|
2258
2210
|
if (typeof url === 'function') {
|
|
2259
2211
|
return new exports.Request('GET', method).end(url);
|
|
2260
2212
|
}
|
|
2261
|
-
|
|
2262
2213
|
if (arguments.length === 1) {
|
|
2263
2214
|
return new exports.Request('GET', method);
|
|
2264
2215
|
}
|
|
@@ -2267,16 +2218,13 @@ module.exports = function (method, url) {
|
|
|
2267
2218
|
exports = module.exports;
|
|
2268
2219
|
const request = exports;
|
|
2269
2220
|
exports.Request = Request;
|
|
2270
|
-
|
|
2271
2221
|
request.getXHR = () => {
|
|
2272
2222
|
if (root.XMLHttpRequest) {
|
|
2273
2223
|
return new root.XMLHttpRequest();
|
|
2274
2224
|
}
|
|
2275
2225
|
throw new Error('Browser-only version of superagent could not find XHR');
|
|
2276
2226
|
};
|
|
2277
|
-
|
|
2278
2227
|
const trim = ''.trim ? s => s.trim() : s => s.replace(/(^\s*|\s*$)/g, '');
|
|
2279
|
-
|
|
2280
2228
|
function serialize(object) {
|
|
2281
2229
|
if (!isObject(object)) return object;
|
|
2282
2230
|
const pairs = [];
|
|
@@ -2285,7 +2233,6 @@ function serialize(object) {
|
|
|
2285
2233
|
}
|
|
2286
2234
|
return pairs.join('&');
|
|
2287
2235
|
}
|
|
2288
|
-
|
|
2289
2236
|
function pushEncodedKeyValuePair(pairs, key, value) {
|
|
2290
2237
|
if (value === undefined) return;
|
|
2291
2238
|
if (value === null) {
|
|
@@ -2304,9 +2251,7 @@ function pushEncodedKeyValuePair(pairs, key, value) {
|
|
|
2304
2251
|
pairs.push(encodeURI(key) + '=' + encodeURIComponent(value));
|
|
2305
2252
|
}
|
|
2306
2253
|
}
|
|
2307
|
-
|
|
2308
2254
|
request.serializeObject = serialize;
|
|
2309
|
-
|
|
2310
2255
|
function parseString(string_) {
|
|
2311
2256
|
const object = {};
|
|
2312
2257
|
const pairs = string_.split('&');
|
|
@@ -2323,9 +2268,7 @@ function parseString(string_) {
|
|
|
2323
2268
|
}
|
|
2324
2269
|
return object;
|
|
2325
2270
|
}
|
|
2326
|
-
|
|
2327
2271
|
request.parseString = parseString;
|
|
2328
|
-
|
|
2329
2272
|
request.types = {
|
|
2330
2273
|
html: 'text/html',
|
|
2331
2274
|
json: 'application/json',
|
|
@@ -2334,17 +2277,14 @@ request.types = {
|
|
|
2334
2277
|
form: 'application/x-www-form-urlencoded',
|
|
2335
2278
|
'form-data': 'application/x-www-form-urlencoded'
|
|
2336
2279
|
};
|
|
2337
|
-
|
|
2338
2280
|
request.serialize = {
|
|
2339
2281
|
'application/x-www-form-urlencoded': qs.stringify,
|
|
2340
2282
|
'application/json': safeStringify
|
|
2341
2283
|
};
|
|
2342
|
-
|
|
2343
2284
|
request.parse = {
|
|
2344
2285
|
'application/x-www-form-urlencoded': parseString,
|
|
2345
2286
|
'application/json': JSON.parse
|
|
2346
2287
|
};
|
|
2347
|
-
|
|
2348
2288
|
function parseHeader(string_) {
|
|
2349
2289
|
const lines = string_.split(/\r?\n/);
|
|
2350
2290
|
const fields = {};
|
|
@@ -2364,11 +2304,9 @@ function parseHeader(string_) {
|
|
|
2364
2304
|
}
|
|
2365
2305
|
return fields;
|
|
2366
2306
|
}
|
|
2367
|
-
|
|
2368
2307
|
function isJSON(mime) {
|
|
2369
2308
|
return /[/+]json($|[^-\w])/i.test(mime);
|
|
2370
2309
|
}
|
|
2371
|
-
|
|
2372
2310
|
function Response(request_) {
|
|
2373
2311
|
this.req = request_;
|
|
2374
2312
|
this.xhr = this.req.xhr;
|
|
@@ -2392,7 +2330,6 @@ function Response(request_) {
|
|
|
2392
2330
|
}
|
|
2393
2331
|
}
|
|
2394
2332
|
mixin(Response.prototype, ResponseBase.prototype);
|
|
2395
|
-
|
|
2396
2333
|
Response.prototype._parseBody = function (string_) {
|
|
2397
2334
|
let parse = request.parse[this.type];
|
|
2398
2335
|
if (this.req._parser) {
|
|
@@ -2403,7 +2340,6 @@ Response.prototype._parseBody = function (string_) {
|
|
|
2403
2340
|
}
|
|
2404
2341
|
return parse && string_ && (string_.length > 0 || string_ instanceof Object) ? parse(string_) : null;
|
|
2405
2342
|
};
|
|
2406
|
-
|
|
2407
2343
|
Response.prototype.toError = function () {
|
|
2408
2344
|
const {
|
|
2409
2345
|
req
|
|
@@ -2421,9 +2357,7 @@ Response.prototype.toError = function () {
|
|
|
2421
2357
|
error.url = url;
|
|
2422
2358
|
return error;
|
|
2423
2359
|
};
|
|
2424
|
-
|
|
2425
2360
|
request.Response = Response;
|
|
2426
|
-
|
|
2427
2361
|
function Request(method, url) {
|
|
2428
2362
|
const self = this;
|
|
2429
2363
|
this._query = this._query || [];
|
|
@@ -2459,7 +2393,6 @@ function Request(method, url) {
|
|
|
2459
2393
|
} catch (err) {
|
|
2460
2394
|
new_error = err;
|
|
2461
2395
|
}
|
|
2462
|
-
|
|
2463
2396
|
if (new_error) {
|
|
2464
2397
|
new_error.original = error;
|
|
2465
2398
|
new_error.response = res;
|
|
@@ -2470,20 +2403,16 @@ function Request(method, url) {
|
|
|
2470
2403
|
}
|
|
2471
2404
|
});
|
|
2472
2405
|
}
|
|
2473
|
-
|
|
2474
2406
|
Emitter(Request.prototype);
|
|
2475
2407
|
mixin(Request.prototype, RequestBase.prototype);
|
|
2476
|
-
|
|
2477
2408
|
Request.prototype.type = function (type) {
|
|
2478
2409
|
this.set('Content-Type', request.types[type] || type);
|
|
2479
2410
|
return this;
|
|
2480
2411
|
};
|
|
2481
|
-
|
|
2482
2412
|
Request.prototype.accept = function (type) {
|
|
2483
2413
|
this.set('Accept', request.types[type] || type);
|
|
2484
2414
|
return this;
|
|
2485
2415
|
};
|
|
2486
|
-
|
|
2487
2416
|
Request.prototype.auth = function (user, pass, options) {
|
|
2488
2417
|
if (arguments.length === 1) pass = '';
|
|
2489
2418
|
if (typeof pass === 'object' && pass !== null) {
|
|
@@ -2503,13 +2432,11 @@ Request.prototype.auth = function (user, pass, options) {
|
|
|
2503
2432
|
};
|
|
2504
2433
|
return this._auth(user, pass, options, encoder);
|
|
2505
2434
|
};
|
|
2506
|
-
|
|
2507
2435
|
Request.prototype.query = function (value) {
|
|
2508
2436
|
if (typeof value !== 'string') value = serialize(value);
|
|
2509
2437
|
if (value) this._query.push(value);
|
|
2510
2438
|
return this;
|
|
2511
2439
|
};
|
|
2512
|
-
|
|
2513
2440
|
Request.prototype.attach = function (field, file, options) {
|
|
2514
2441
|
if (file) {
|
|
2515
2442
|
if (this._data) {
|
|
@@ -2525,7 +2452,6 @@ Request.prototype._getFormData = function () {
|
|
|
2525
2452
|
}
|
|
2526
2453
|
return this._formData;
|
|
2527
2454
|
};
|
|
2528
|
-
|
|
2529
2455
|
Request.prototype.callback = function (error, res) {
|
|
2530
2456
|
if (this._shouldRetry(error, res)) {
|
|
2531
2457
|
return this._retry();
|
|
@@ -2538,7 +2464,6 @@ Request.prototype.callback = function (error, res) {
|
|
|
2538
2464
|
}
|
|
2539
2465
|
fn(error, res);
|
|
2540
2466
|
};
|
|
2541
|
-
|
|
2542
2467
|
Request.prototype.crossDomainError = function () {
|
|
2543
2468
|
const error = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.');
|
|
2544
2469
|
error.crossDomain = true;
|
|
@@ -2547,44 +2472,36 @@ Request.prototype.crossDomainError = function () {
|
|
|
2547
2472
|
error.url = this.url;
|
|
2548
2473
|
this.callback(error);
|
|
2549
2474
|
};
|
|
2550
|
-
|
|
2551
2475
|
Request.prototype.agent = function () {
|
|
2552
2476
|
console.warn('This is not supported in browser version of superagent');
|
|
2553
2477
|
return this;
|
|
2554
2478
|
};
|
|
2555
2479
|
Request.prototype.ca = Request.prototype.agent;
|
|
2556
2480
|
Request.prototype.buffer = Request.prototype.ca;
|
|
2557
|
-
|
|
2558
2481
|
Request.prototype.write = () => {
|
|
2559
2482
|
throw new Error('Streaming is not supported in browser version of superagent');
|
|
2560
2483
|
};
|
|
2561
2484
|
Request.prototype.pipe = Request.prototype.write;
|
|
2562
|
-
|
|
2563
2485
|
Request.prototype._isHost = function (object) {
|
|
2564
2486
|
return object && typeof object === 'object' && !Array.isArray(object) && Object.prototype.toString.call(object) !== '[object Object]';
|
|
2565
2487
|
};
|
|
2566
|
-
|
|
2567
2488
|
Request.prototype.end = function (fn) {
|
|
2568
2489
|
if (this._endCalled) {
|
|
2569
2490
|
console.warn('Warning: .end() was called twice. This is not supported in superagent');
|
|
2570
2491
|
}
|
|
2571
2492
|
this._endCalled = true;
|
|
2572
|
-
|
|
2573
2493
|
this._callback = fn || noop;
|
|
2574
|
-
|
|
2575
2494
|
this._finalizeQueryString();
|
|
2576
2495
|
this._end();
|
|
2577
2496
|
};
|
|
2578
2497
|
Request.prototype._setUploadTimeout = function () {
|
|
2579
2498
|
const self = this;
|
|
2580
|
-
|
|
2581
2499
|
if (this._uploadTimeout && !this._uploadTimeoutTimer) {
|
|
2582
2500
|
this._uploadTimeoutTimer = setTimeout(() => {
|
|
2583
2501
|
self._timeoutError('Upload timeout of ', self._uploadTimeout, 'ETIMEDOUT');
|
|
2584
2502
|
}, this._uploadTimeout);
|
|
2585
2503
|
}
|
|
2586
2504
|
};
|
|
2587
|
-
|
|
2588
2505
|
Request.prototype._end = function () {
|
|
2589
2506
|
if (this._aborted) return this.callback(new Error('The request has been aborted even before .end() was called'));
|
|
2590
2507
|
const self = this;
|
|
@@ -2594,7 +2511,6 @@ Request.prototype._end = function () {
|
|
|
2594
2511
|
} = this;
|
|
2595
2512
|
let data = this._formData || this._data;
|
|
2596
2513
|
this._setTimeouts();
|
|
2597
|
-
|
|
2598
2514
|
xhr.addEventListener('readystatechange', () => {
|
|
2599
2515
|
const {
|
|
2600
2516
|
readyState
|
|
@@ -2605,7 +2521,6 @@ Request.prototype._end = function () {
|
|
|
2605
2521
|
if (readyState !== 4) {
|
|
2606
2522
|
return;
|
|
2607
2523
|
}
|
|
2608
|
-
|
|
2609
2524
|
let status;
|
|
2610
2525
|
try {
|
|
2611
2526
|
status = xhr.status;
|
|
@@ -2618,7 +2533,6 @@ Request.prototype._end = function () {
|
|
|
2618
2533
|
}
|
|
2619
2534
|
self.emit('end');
|
|
2620
2535
|
});
|
|
2621
|
-
|
|
2622
2536
|
const handleProgress = (direction, e) => {
|
|
2623
2537
|
if (e.total > 0) {
|
|
2624
2538
|
e.percent = e.loaded / e.total * 100;
|
|
@@ -2635,14 +2549,11 @@ Request.prototype._end = function () {
|
|
|
2635
2549
|
if (xhr.upload) {
|
|
2636
2550
|
xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload'));
|
|
2637
2551
|
}
|
|
2638
|
-
} catch (err) {
|
|
2639
|
-
}
|
|
2552
|
+
} catch (err) {}
|
|
2640
2553
|
}
|
|
2641
|
-
|
|
2642
2554
|
if (xhr.upload) {
|
|
2643
2555
|
this._setUploadTimeout();
|
|
2644
2556
|
}
|
|
2645
|
-
|
|
2646
2557
|
try {
|
|
2647
2558
|
if (this.username && this.password) {
|
|
2648
2559
|
xhr.open(this.method, this.url, true, this.username, this.password);
|
|
@@ -2652,9 +2563,7 @@ Request.prototype._end = function () {
|
|
|
2652
2563
|
} catch (err) {
|
|
2653
2564
|
return this.callback(err);
|
|
2654
2565
|
}
|
|
2655
|
-
|
|
2656
2566
|
if (this._withCredentials) xhr.withCredentials = true;
|
|
2657
|
-
|
|
2658
2567
|
if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) {
|
|
2659
2568
|
const contentType = this._header['content-type'];
|
|
2660
2569
|
let serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
|
|
@@ -2663,7 +2572,6 @@ Request.prototype._end = function () {
|
|
|
2663
2572
|
}
|
|
2664
2573
|
if (serialize) data = serialize(data);
|
|
2665
2574
|
}
|
|
2666
|
-
|
|
2667
2575
|
for (const field in this.header) {
|
|
2668
2576
|
if (this.header[field] === null) continue;
|
|
2669
2577
|
if (hasOwn(this.header, field)) xhr.setRequestHeader(field, this.header[field]);
|
|
@@ -2671,9 +2579,7 @@ Request.prototype._end = function () {
|
|
|
2671
2579
|
if (this._responseType) {
|
|
2672
2580
|
xhr.responseType = this._responseType;
|
|
2673
2581
|
}
|
|
2674
|
-
|
|
2675
2582
|
this.emit('request', this);
|
|
2676
|
-
|
|
2677
2583
|
xhr.send(typeof data === 'undefined' ? null : data);
|
|
2678
2584
|
};
|
|
2679
2585
|
request.agent = () => new Agent();
|
|
@@ -2688,7 +2594,6 @@ for (const method of ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE']) {
|
|
|
2688
2594
|
};
|
|
2689
2595
|
}
|
|
2690
2596
|
Agent.prototype.del = Agent.prototype.delete;
|
|
2691
|
-
|
|
2692
2597
|
request.get = (url, data, fn) => {
|
|
2693
2598
|
const request_ = request('GET', url);
|
|
2694
2599
|
if (typeof data === 'function') {
|
|
@@ -2699,7 +2604,6 @@ request.get = (url, data, fn) => {
|
|
|
2699
2604
|
if (fn) request_.end(fn);
|
|
2700
2605
|
return request_;
|
|
2701
2606
|
};
|
|
2702
|
-
|
|
2703
2607
|
request.head = (url, data, fn) => {
|
|
2704
2608
|
const request_ = request('HEAD', url);
|
|
2705
2609
|
if (typeof data === 'function') {
|
|
@@ -2710,7 +2614,6 @@ request.head = (url, data, fn) => {
|
|
|
2710
2614
|
if (fn) request_.end(fn);
|
|
2711
2615
|
return request_;
|
|
2712
2616
|
};
|
|
2713
|
-
|
|
2714
2617
|
request.options = (url, data, fn) => {
|
|
2715
2618
|
const request_ = request('OPTIONS', url);
|
|
2716
2619
|
if (typeof data === 'function') {
|
|
@@ -2721,7 +2624,6 @@ request.options = (url, data, fn) => {
|
|
|
2721
2624
|
if (fn) request_.end(fn);
|
|
2722
2625
|
return request_;
|
|
2723
2626
|
};
|
|
2724
|
-
|
|
2725
2627
|
function del(url, data, fn) {
|
|
2726
2628
|
const request_ = request('DELETE', url);
|
|
2727
2629
|
if (typeof data === 'function') {
|
|
@@ -2734,7 +2636,6 @@ function del(url, data, fn) {
|
|
|
2734
2636
|
}
|
|
2735
2637
|
request.del = del;
|
|
2736
2638
|
request.delete = del;
|
|
2737
|
-
|
|
2738
2639
|
request.patch = (url, data, fn) => {
|
|
2739
2640
|
const request_ = request('PATCH', url);
|
|
2740
2641
|
if (typeof data === 'function') {
|
|
@@ -2745,7 +2646,6 @@ request.patch = (url, data, fn) => {
|
|
|
2745
2646
|
if (fn) request_.end(fn);
|
|
2746
2647
|
return request_;
|
|
2747
2648
|
};
|
|
2748
|
-
|
|
2749
2649
|
request.post = (url, data, fn) => {
|
|
2750
2650
|
const request_ = request('POST', url);
|
|
2751
2651
|
if (typeof data === 'function') {
|
|
@@ -2756,7 +2656,6 @@ request.post = (url, data, fn) => {
|
|
|
2756
2656
|
if (fn) request_.end(fn);
|
|
2757
2657
|
return request_;
|
|
2758
2658
|
};
|
|
2759
|
-
|
|
2760
2659
|
request.put = (url, data, fn) => {
|
|
2761
2660
|
const request_ = request('PUT', url);
|
|
2762
2661
|
if (typeof data === 'function') {
|
|
@@ -2771,16 +2670,12 @@ request.put = (url, data, fn) => {
|
|
|
2771
2670
|
},{"./agent-base":20,"./request-base":22,"./response-base":23,"./utils":24,"component-emitter":4,"fast-safe-stringify":5,"qs":15}],22:[function(require,module,exports){
|
|
2772
2671
|
(function (process){(function (){
|
|
2773
2672
|
const semver = require('semver');
|
|
2774
|
-
|
|
2775
2673
|
const {
|
|
2776
2674
|
isObject,
|
|
2777
2675
|
hasOwn
|
|
2778
2676
|
} = require('./utils');
|
|
2779
|
-
|
|
2780
2677
|
module.exports = RequestBase;
|
|
2781
|
-
|
|
2782
2678
|
function RequestBase() {}
|
|
2783
|
-
|
|
2784
2679
|
RequestBase.prototype.clearTimeout = function () {
|
|
2785
2680
|
clearTimeout(this._timer);
|
|
2786
2681
|
clearTimeout(this._responseTimeoutTimer);
|
|
@@ -2790,22 +2685,18 @@ RequestBase.prototype.clearTimeout = function () {
|
|
|
2790
2685
|
delete this._uploadTimeoutTimer;
|
|
2791
2686
|
return this;
|
|
2792
2687
|
};
|
|
2793
|
-
|
|
2794
2688
|
RequestBase.prototype.parse = function (fn) {
|
|
2795
2689
|
this._parser = fn;
|
|
2796
2690
|
return this;
|
|
2797
2691
|
};
|
|
2798
|
-
|
|
2799
2692
|
RequestBase.prototype.responseType = function (value) {
|
|
2800
2693
|
this._responseType = value;
|
|
2801
2694
|
return this;
|
|
2802
2695
|
};
|
|
2803
|
-
|
|
2804
2696
|
RequestBase.prototype.serialize = function (fn) {
|
|
2805
2697
|
this._serializer = fn;
|
|
2806
2698
|
return this;
|
|
2807
2699
|
};
|
|
2808
|
-
|
|
2809
2700
|
RequestBase.prototype.timeout = function (options) {
|
|
2810
2701
|
if (!options || typeof options !== 'object') {
|
|
2811
2702
|
this._timeout = options;
|
|
@@ -2832,7 +2723,6 @@ RequestBase.prototype.timeout = function (options) {
|
|
|
2832
2723
|
}
|
|
2833
2724
|
return this;
|
|
2834
2725
|
};
|
|
2835
|
-
|
|
2836
2726
|
RequestBase.prototype.retry = function (count, fn) {
|
|
2837
2727
|
if (arguments.length === 0 || count === true) count = 1;
|
|
2838
2728
|
if (count <= 0) count = 0;
|
|
@@ -2841,10 +2731,8 @@ RequestBase.prototype.retry = function (count, fn) {
|
|
|
2841
2731
|
this._retryCallback = fn;
|
|
2842
2732
|
return this;
|
|
2843
2733
|
};
|
|
2844
|
-
|
|
2845
2734
|
const ERROR_CODES = new Set(['ETIMEDOUT', 'ECONNRESET', 'EADDRINUSE', 'ECONNREFUSED', 'EPIPE', 'ENOTFOUND', 'ENETUNREACH', 'EAI_AGAIN']);
|
|
2846
2735
|
const STATUS_CODES = new Set([408, 413, 429, 500, 502, 503, 504, 521, 522, 524]);
|
|
2847
|
-
|
|
2848
2736
|
RequestBase.prototype._shouldRetry = function (error, res) {
|
|
2849
2737
|
if (!this._maxRetries || this._retries++ >= this._maxRetries) {
|
|
2850
2738
|
return false;
|
|
@@ -2858,7 +2746,6 @@ RequestBase.prototype._shouldRetry = function (error, res) {
|
|
|
2858
2746
|
console.error(err);
|
|
2859
2747
|
}
|
|
2860
2748
|
}
|
|
2861
|
-
|
|
2862
2749
|
if (res && res.status && STATUS_CODES.has(res.status)) return true;
|
|
2863
2750
|
if (error) {
|
|
2864
2751
|
if (error.code && ERROR_CODES.has(error.code)) return true;
|
|
@@ -2867,10 +2754,8 @@ RequestBase.prototype._shouldRetry = function (error, res) {
|
|
|
2867
2754
|
}
|
|
2868
2755
|
return false;
|
|
2869
2756
|
};
|
|
2870
|
-
|
|
2871
2757
|
RequestBase.prototype._retry = function () {
|
|
2872
2758
|
this.clearTimeout();
|
|
2873
|
-
|
|
2874
2759
|
if (this.req) {
|
|
2875
2760
|
this.req = null;
|
|
2876
2761
|
this.req = this.request();
|
|
@@ -2880,7 +2765,6 @@ RequestBase.prototype._retry = function () {
|
|
|
2880
2765
|
this.timedoutError = null;
|
|
2881
2766
|
return this._end();
|
|
2882
2767
|
};
|
|
2883
|
-
|
|
2884
2768
|
RequestBase.prototype.then = function (resolve, reject) {
|
|
2885
2769
|
if (!this._fullfilledPromise) {
|
|
2886
2770
|
const self = this;
|
|
@@ -2913,7 +2797,6 @@ RequestBase.prototype.then = function (resolve, reject) {
|
|
|
2913
2797
|
RequestBase.prototype.catch = function (callback) {
|
|
2914
2798
|
return this.then(undefined, callback);
|
|
2915
2799
|
};
|
|
2916
|
-
|
|
2917
2800
|
RequestBase.prototype.use = function (fn) {
|
|
2918
2801
|
fn(this);
|
|
2919
2802
|
return this;
|
|
@@ -2932,13 +2815,10 @@ RequestBase.prototype._isResponseOK = function (res) {
|
|
|
2932
2815
|
}
|
|
2933
2816
|
return res.status >= 200 && res.status < 300;
|
|
2934
2817
|
};
|
|
2935
|
-
|
|
2936
2818
|
RequestBase.prototype.get = function (field) {
|
|
2937
2819
|
return this._header[field.toLowerCase()];
|
|
2938
2820
|
};
|
|
2939
|
-
|
|
2940
2821
|
RequestBase.prototype.getHeader = RequestBase.prototype.get;
|
|
2941
|
-
|
|
2942
2822
|
RequestBase.prototype.set = function (field, value) {
|
|
2943
2823
|
if (isObject(field)) {
|
|
2944
2824
|
for (const key in field) {
|
|
@@ -2950,13 +2830,11 @@ RequestBase.prototype.set = function (field, value) {
|
|
|
2950
2830
|
this.header[field] = value;
|
|
2951
2831
|
return this;
|
|
2952
2832
|
};
|
|
2953
|
-
|
|
2954
2833
|
RequestBase.prototype.unset = function (field) {
|
|
2955
2834
|
delete this._header[field.toLowerCase()];
|
|
2956
2835
|
delete this.header[field];
|
|
2957
2836
|
return this;
|
|
2958
2837
|
};
|
|
2959
|
-
|
|
2960
2838
|
RequestBase.prototype.field = function (name, value, options) {
|
|
2961
2839
|
if (name === null || undefined === name) {
|
|
2962
2840
|
throw new Error('.field(name, val) name can not be empty');
|
|
@@ -2976,18 +2854,15 @@ RequestBase.prototype.field = function (name, value, options) {
|
|
|
2976
2854
|
}
|
|
2977
2855
|
return this;
|
|
2978
2856
|
}
|
|
2979
|
-
|
|
2980
2857
|
if (value === null || undefined === value) {
|
|
2981
2858
|
throw new Error('.field(name, val) val can not be empty');
|
|
2982
2859
|
}
|
|
2983
2860
|
if (typeof value === 'boolean') {
|
|
2984
2861
|
value = String(value);
|
|
2985
2862
|
}
|
|
2986
|
-
|
|
2987
2863
|
if (options) this._getFormData().append(name, value, options);else this._getFormData().append(name, value);
|
|
2988
2864
|
return this;
|
|
2989
2865
|
};
|
|
2990
|
-
|
|
2991
2866
|
RequestBase.prototype.abort = function () {
|
|
2992
2867
|
if (this._aborted) {
|
|
2993
2868
|
return this;
|
|
@@ -3002,7 +2877,6 @@ RequestBase.prototype.abort = function () {
|
|
|
3002
2877
|
}
|
|
3003
2878
|
this.req.abort();
|
|
3004
2879
|
}
|
|
3005
|
-
|
|
3006
2880
|
this.clearTimeout();
|
|
3007
2881
|
this.emit('abort');
|
|
3008
2882
|
return this;
|
|
@@ -3024,18 +2898,15 @@ RequestBase.prototype._auth = function (user, pass, options, base64Encoder) {
|
|
|
3024
2898
|
}
|
|
3025
2899
|
return this;
|
|
3026
2900
|
};
|
|
3027
|
-
|
|
3028
2901
|
RequestBase.prototype.withCredentials = function (on) {
|
|
3029
2902
|
if (on === undefined) on = true;
|
|
3030
2903
|
this._withCredentials = on;
|
|
3031
2904
|
return this;
|
|
3032
2905
|
};
|
|
3033
|
-
|
|
3034
2906
|
RequestBase.prototype.redirects = function (n) {
|
|
3035
2907
|
this._maxRedirects = n;
|
|
3036
2908
|
return this;
|
|
3037
2909
|
};
|
|
3038
|
-
|
|
3039
2910
|
RequestBase.prototype.maxResponseSize = function (n) {
|
|
3040
2911
|
if (typeof n !== 'number') {
|
|
3041
2912
|
throw new TypeError('Invalid argument');
|
|
@@ -3043,7 +2914,6 @@ RequestBase.prototype.maxResponseSize = function (n) {
|
|
|
3043
2914
|
this._maxResponseSize = n;
|
|
3044
2915
|
return this;
|
|
3045
2916
|
};
|
|
3046
|
-
|
|
3047
2917
|
RequestBase.prototype.toJSON = function () {
|
|
3048
2918
|
return {
|
|
3049
2919
|
method: this.method,
|
|
@@ -3052,7 +2922,6 @@ RequestBase.prototype.toJSON = function () {
|
|
|
3052
2922
|
headers: this._header
|
|
3053
2923
|
};
|
|
3054
2924
|
};
|
|
3055
|
-
|
|
3056
2925
|
RequestBase.prototype.send = function (data) {
|
|
3057
2926
|
const isObject_ = isObject(data);
|
|
3058
2927
|
let type = this._header['content-type'];
|
|
@@ -3068,7 +2937,6 @@ RequestBase.prototype.send = function (data) {
|
|
|
3068
2937
|
} else if (data && this._data && this._isHost(this._data)) {
|
|
3069
2938
|
throw new Error("Can't merge these send calls");
|
|
3070
2939
|
}
|
|
3071
|
-
|
|
3072
2940
|
if (isObject_ && isObject(this._data)) {
|
|
3073
2941
|
for (const key in data) {
|
|
3074
2942
|
if (hasOwn(data, key)) this._data[key] = data[key];
|
|
@@ -3088,23 +2956,19 @@ RequestBase.prototype.send = function (data) {
|
|
|
3088
2956
|
if (!isObject_ || this._isHost(data)) {
|
|
3089
2957
|
return this;
|
|
3090
2958
|
}
|
|
3091
|
-
|
|
3092
2959
|
if (!type) this.type('json');
|
|
3093
2960
|
return this;
|
|
3094
2961
|
};
|
|
3095
|
-
|
|
3096
2962
|
RequestBase.prototype.sortQuery = function (sort) {
|
|
3097
2963
|
this._sort = typeof sort === 'undefined' ? true : sort;
|
|
3098
2964
|
return this;
|
|
3099
2965
|
};
|
|
3100
|
-
|
|
3101
2966
|
RequestBase.prototype._finalizeQueryString = function () {
|
|
3102
2967
|
const query = this._query.join('&');
|
|
3103
2968
|
if (query) {
|
|
3104
2969
|
this.url += (this.url.includes('?') ? '&' : '?') + query;
|
|
3105
2970
|
}
|
|
3106
2971
|
this._query.length = 0;
|
|
3107
|
-
|
|
3108
2972
|
if (this._sort) {
|
|
3109
2973
|
const index = this.url.indexOf('?');
|
|
3110
2974
|
if (index >= 0) {
|
|
@@ -3118,11 +2982,9 @@ RequestBase.prototype._finalizeQueryString = function () {
|
|
|
3118
2982
|
}
|
|
3119
2983
|
}
|
|
3120
2984
|
};
|
|
3121
|
-
|
|
3122
2985
|
RequestBase.prototype._appendQueryString = () => {
|
|
3123
2986
|
console.warn('Unsupported');
|
|
3124
2987
|
};
|
|
3125
|
-
|
|
3126
2988
|
RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
3127
2989
|
if (this._aborted) {
|
|
3128
2990
|
return;
|
|
@@ -3138,13 +3000,11 @@ RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
|
3138
3000
|
};
|
|
3139
3001
|
RequestBase.prototype._setTimeouts = function () {
|
|
3140
3002
|
const self = this;
|
|
3141
|
-
|
|
3142
3003
|
if (this._timeout && !this._timer) {
|
|
3143
3004
|
this._timer = setTimeout(() => {
|
|
3144
3005
|
self._timeoutError('Timeout of ', self._timeout, 'ETIME');
|
|
3145
3006
|
}, this._timeout);
|
|
3146
3007
|
}
|
|
3147
|
-
|
|
3148
3008
|
if (this._responseTimeout && !this._responseTimeoutTimer) {
|
|
3149
3009
|
this._responseTimeoutTimer = setTimeout(() => {
|
|
3150
3010
|
self._timeoutError('Response timeout of ', self._responseTimeout, 'ETIMEDOUT');
|
|
@@ -3154,51 +3014,37 @@ RequestBase.prototype._setTimeouts = function () {
|
|
|
3154
3014
|
|
|
3155
3015
|
}).call(this)}).call(this,require('_process'))
|
|
3156
3016
|
},{"./utils":24,"_process":13,"semver":1}],23:[function(require,module,exports){
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
3017
|
const utils = require('./utils');
|
|
3160
|
-
|
|
3161
3018
|
module.exports = ResponseBase;
|
|
3162
|
-
|
|
3163
3019
|
function ResponseBase() {}
|
|
3164
|
-
|
|
3165
3020
|
ResponseBase.prototype.get = function (field) {
|
|
3166
3021
|
return this.header[field.toLowerCase()];
|
|
3167
3022
|
};
|
|
3168
|
-
|
|
3169
3023
|
ResponseBase.prototype._setHeaderProperties = function (header) {
|
|
3170
|
-
|
|
3171
3024
|
const ct = header['content-type'] || '';
|
|
3172
3025
|
this.type = utils.type(ct);
|
|
3173
|
-
|
|
3174
3026
|
const parameters = utils.params(ct);
|
|
3175
3027
|
for (const key in parameters) {
|
|
3176
3028
|
if (Object.prototype.hasOwnProperty.call(parameters, key)) this[key] = parameters[key];
|
|
3177
3029
|
}
|
|
3178
3030
|
this.links = {};
|
|
3179
|
-
|
|
3180
3031
|
try {
|
|
3181
3032
|
if (header.link) {
|
|
3182
3033
|
this.links = utils.parseLinks(header.link);
|
|
3183
3034
|
}
|
|
3184
|
-
} catch (err) {
|
|
3185
|
-
}
|
|
3035
|
+
} catch (err) {}
|
|
3186
3036
|
};
|
|
3187
|
-
|
|
3188
3037
|
ResponseBase.prototype._setStatusProperties = function (status) {
|
|
3189
3038
|
const type = Math.trunc(status / 100);
|
|
3190
|
-
|
|
3191
3039
|
this.statusCode = status;
|
|
3192
3040
|
this.status = this.statusCode;
|
|
3193
3041
|
this.statusType = type;
|
|
3194
|
-
|
|
3195
3042
|
this.info = type === 1;
|
|
3196
3043
|
this.ok = type === 2;
|
|
3197
3044
|
this.redirect = type === 3;
|
|
3198
3045
|
this.clientError = type === 4;
|
|
3199
3046
|
this.serverError = type === 5;
|
|
3200
3047
|
this.error = type === 4 || type === 5 ? this.toError() : false;
|
|
3201
|
-
|
|
3202
3048
|
this.created = status === 201;
|
|
3203
3049
|
this.accepted = status === 202;
|
|
3204
3050
|
this.noContent = status === 204;
|
|
@@ -3211,10 +3057,7 @@ ResponseBase.prototype._setStatusProperties = function (status) {
|
|
|
3211
3057
|
};
|
|
3212
3058
|
|
|
3213
3059
|
},{"./utils":24}],24:[function(require,module,exports){
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
3060
|
exports.type = string_ => string_.split(/ *; */).shift();
|
|
3217
|
-
|
|
3218
3061
|
exports.params = value => {
|
|
3219
3062
|
const object = {};
|
|
3220
3063
|
for (const string_ of value.split(/ *; */)) {
|
|
@@ -3225,7 +3068,6 @@ exports.params = value => {
|
|
|
3225
3068
|
}
|
|
3226
3069
|
return object;
|
|
3227
3070
|
};
|
|
3228
|
-
|
|
3229
3071
|
exports.parseLinks = value => {
|
|
3230
3072
|
const object = {};
|
|
3231
3073
|
for (const string_ of value.split(/ *, */)) {
|
|
@@ -3236,7 +3078,6 @@ exports.parseLinks = value => {
|
|
|
3236
3078
|
}
|
|
3237
3079
|
return object;
|
|
3238
3080
|
};
|
|
3239
|
-
|
|
3240
3081
|
exports.cleanHeader = (header, changesOrigin) => {
|
|
3241
3082
|
delete header['content-type'];
|
|
3242
3083
|
delete header['content-length'];
|
|
@@ -3248,11 +3089,9 @@ exports.cleanHeader = (header, changesOrigin) => {
|
|
|
3248
3089
|
}
|
|
3249
3090
|
return header;
|
|
3250
3091
|
};
|
|
3251
|
-
|
|
3252
3092
|
exports.isObject = object => {
|
|
3253
3093
|
return object !== null && typeof object === 'object';
|
|
3254
3094
|
};
|
|
3255
|
-
|
|
3256
3095
|
exports.hasOwn = Object.hasOwn || function (object, property) {
|
|
3257
3096
|
if (object == null) {
|
|
3258
3097
|
throw new TypeError('Cannot convert undefined or null to object');
|