superagent 7.1.4 → 8.0.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/README.md +35 -38
- package/dist/superagent.js +234 -342
- package/dist/superagent.min.js +1 -1
- package/lib/agent-base.js +8 -20
- package/lib/client.js +88 -125
- package/lib/node/agent.js +19 -23
- package/lib/node/http2wrapper.js +51 -61
- package/lib/node/index.js +191 -215
- package/lib/node/parsers/image.js +5 -5
- package/lib/node/parsers/index.js +3 -2
- package/lib/node/parsers/json.js +5 -5
- package/lib/node/parsers/text.js +3 -3
- package/lib/node/parsers/urlencoded.js +5 -5
- package/lib/node/response.js +16 -14
- package/lib/node/unzip.js +15 -15
- package/lib/request-base.js +36 -40
- package/lib/response-base.js +7 -7
- package/lib/utils.js +21 -27
- package/package.json +16 -17
- package/HISTORY.md +0 -692
package/dist/superagent.js
CHANGED
|
@@ -176,8 +176,6 @@ Emitter.prototype.hasListeners = function (event) {
|
|
|
176
176
|
},{}],5:[function(require,module,exports){
|
|
177
177
|
"use strict";
|
|
178
178
|
|
|
179
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
180
|
-
|
|
181
179
|
module.exports = stringify;
|
|
182
180
|
stringify.default = stringify;
|
|
183
181
|
stringify.stable = deterministicStringify;
|
|
@@ -247,7 +245,7 @@ function decirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
247
245
|
depth += 1;
|
|
248
246
|
var i;
|
|
249
247
|
|
|
250
|
-
if (
|
|
248
|
+
if (typeof val === 'object' && val !== null) {
|
|
251
249
|
for (i = 0; i < stack.length; i++) {
|
|
252
250
|
if (stack[i] === val) {
|
|
253
251
|
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
@@ -331,7 +329,7 @@ function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
|
|
|
331
329
|
depth += 1;
|
|
332
330
|
var i;
|
|
333
331
|
|
|
334
|
-
if (
|
|
332
|
+
if (typeof val === 'object' && val !== null) {
|
|
335
333
|
for (i = 0; i < stack.length; i++) {
|
|
336
334
|
if (stack[i] === val) {
|
|
337
335
|
setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
|
|
@@ -424,7 +422,7 @@ module.exports = function bind(that) {
|
|
|
424
422
|
var args = slice.call(arguments, 1);
|
|
425
423
|
var bound;
|
|
426
424
|
|
|
427
|
-
var binder = function
|
|
425
|
+
var binder = function () {
|
|
428
426
|
if (this instanceof bound) {
|
|
429
427
|
var result = target.apply(this, args.concat(slice.call(arguments)));
|
|
430
428
|
|
|
@@ -468,14 +466,12 @@ module.exports = Function.prototype.bind || implementation;
|
|
|
468
466
|
},{"./implementation":6}],8:[function(require,module,exports){
|
|
469
467
|
'use strict';
|
|
470
468
|
|
|
471
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
472
|
-
|
|
473
469
|
var undefined;
|
|
474
470
|
var $SyntaxError = SyntaxError;
|
|
475
471
|
var $Function = Function;
|
|
476
472
|
var $TypeError = TypeError;
|
|
477
473
|
|
|
478
|
-
var getEvalledConstructor = function
|
|
474
|
+
var getEvalledConstructor = function (expressionSyntax) {
|
|
479
475
|
try {
|
|
480
476
|
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
481
477
|
} catch (e) {}
|
|
@@ -491,7 +487,7 @@ if ($gOPD) {
|
|
|
491
487
|
}
|
|
492
488
|
}
|
|
493
489
|
|
|
494
|
-
var throwTypeError = function
|
|
490
|
+
var throwTypeError = function () {
|
|
495
491
|
throw new $TypeError();
|
|
496
492
|
};
|
|
497
493
|
|
|
@@ -549,7 +545,7 @@ var INTRINSICS = {
|
|
|
549
545
|
'%isFinite%': isFinite,
|
|
550
546
|
'%isNaN%': isNaN,
|
|
551
547
|
'%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
|
|
552
|
-
'%JSON%':
|
|
548
|
+
'%JSON%': typeof JSON === 'object' ? JSON : undefined,
|
|
553
549
|
'%Map%': typeof Map === 'undefined' ? undefined : Map,
|
|
554
550
|
'%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
|
|
555
551
|
'%Math%': Math,
|
|
@@ -672,6 +668,7 @@ var $concat = bind.call(Function.call, Array.prototype.concat);
|
|
|
672
668
|
var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
|
|
673
669
|
var $replace = bind.call(Function.call, String.prototype.replace);
|
|
674
670
|
var $strSlice = bind.call(Function.call, String.prototype.slice);
|
|
671
|
+
var $exec = bind.call(Function.call, RegExp.prototype.exec);
|
|
675
672
|
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
676
673
|
var reEscapeChar = /\\(\\)?/g;
|
|
677
674
|
|
|
@@ -731,6 +728,10 @@ module.exports = function GetIntrinsic(name, allowMissing) {
|
|
|
731
728
|
throw new $TypeError('"allowMissing" argument must be a boolean');
|
|
732
729
|
}
|
|
733
730
|
|
|
731
|
+
if ($exec(/^%?[^%]*%?$/g, name) === null) {
|
|
732
|
+
throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
|
|
733
|
+
}
|
|
734
|
+
|
|
734
735
|
var parts = stringToPath(name);
|
|
735
736
|
var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
|
|
736
737
|
var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
|
|
@@ -797,8 +798,6 @@ module.exports = function GetIntrinsic(name, allowMissing) {
|
|
|
797
798
|
},{"function-bind":7,"has":11,"has-symbols":9}],9:[function(require,module,exports){
|
|
798
799
|
'use strict';
|
|
799
800
|
|
|
800
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
801
|
-
|
|
802
801
|
var origSymbol = typeof Symbol !== 'undefined' && Symbol;
|
|
803
802
|
|
|
804
803
|
var hasSymbolSham = require('./shams');
|
|
@@ -812,11 +811,11 @@ module.exports = function hasNativeSymbols() {
|
|
|
812
811
|
return false;
|
|
813
812
|
}
|
|
814
813
|
|
|
815
|
-
if (
|
|
814
|
+
if (typeof origSymbol('foo') !== 'symbol') {
|
|
816
815
|
return false;
|
|
817
816
|
}
|
|
818
817
|
|
|
819
|
-
if (
|
|
818
|
+
if (typeof Symbol('bar') !== 'symbol') {
|
|
820
819
|
return false;
|
|
821
820
|
}
|
|
822
821
|
|
|
@@ -826,14 +825,12 @@ module.exports = function hasNativeSymbols() {
|
|
|
826
825
|
},{"./shams":10}],10:[function(require,module,exports){
|
|
827
826
|
'use strict';
|
|
828
827
|
|
|
829
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
830
|
-
|
|
831
828
|
module.exports = function hasSymbols() {
|
|
832
829
|
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') {
|
|
833
830
|
return false;
|
|
834
831
|
}
|
|
835
832
|
|
|
836
|
-
if (
|
|
833
|
+
if (typeof Symbol.iterator === 'symbol') {
|
|
837
834
|
return true;
|
|
838
835
|
}
|
|
839
836
|
|
|
@@ -899,8 +896,6 @@ module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
|
|
|
899
896
|
},{"function-bind":7}],12:[function(require,module,exports){
|
|
900
897
|
"use strict";
|
|
901
898
|
|
|
902
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
903
|
-
|
|
904
899
|
var hasMap = typeof Map === 'function' && Map.prototype;
|
|
905
900
|
var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
|
|
906
901
|
var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
|
|
@@ -930,9 +925,9 @@ var $arrSlice = Array.prototype.slice;
|
|
|
930
925
|
var $floor = Math.floor;
|
|
931
926
|
var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
|
|
932
927
|
var gOPS = Object.getOwnPropertySymbols;
|
|
933
|
-
var symToString = typeof Symbol === 'function' &&
|
|
934
|
-
var hasShammedSymbols = typeof Symbol === 'function' &&
|
|
935
|
-
var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (
|
|
928
|
+
var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
|
|
929
|
+
var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';
|
|
930
|
+
var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol') ? Symbol.toStringTag : null;
|
|
936
931
|
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
937
932
|
var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function (O) {
|
|
938
933
|
return O.__proto__;
|
|
@@ -1026,7 +1021,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1026
1021
|
depth = 0;
|
|
1027
1022
|
}
|
|
1028
1023
|
|
|
1029
|
-
if (depth >= maxDepth && maxDepth > 0 &&
|
|
1024
|
+
if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
|
|
1030
1025
|
return isArray(obj) ? '[Array]' : '[Object]';
|
|
1031
1026
|
}
|
|
1032
1027
|
|
|
@@ -1067,7 +1062,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1067
1062
|
|
|
1068
1063
|
if (isSymbol(obj)) {
|
|
1069
1064
|
var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
|
|
1070
|
-
return
|
|
1065
|
+
return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
|
|
1071
1066
|
}
|
|
1072
1067
|
|
|
1073
1068
|
if (isElement(obj)) {
|
|
@@ -1116,7 +1111,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
|
|
|
1116
1111
|
return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
|
|
1117
1112
|
}
|
|
1118
1113
|
|
|
1119
|
-
if (
|
|
1114
|
+
if (typeof obj === 'object' && customInspect) {
|
|
1120
1115
|
if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) {
|
|
1121
1116
|
return utilInspect(obj, {
|
|
1122
1117
|
depth: maxDepth - depth
|
|
@@ -1202,43 +1197,43 @@ function quote(s) {
|
|
|
1202
1197
|
}
|
|
1203
1198
|
|
|
1204
1199
|
function isArray(obj) {
|
|
1205
|
-
return toStr(obj) === '[object Array]' && (!toStringTag || !(
|
|
1200
|
+
return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1206
1201
|
}
|
|
1207
1202
|
|
|
1208
1203
|
function isDate(obj) {
|
|
1209
|
-
return toStr(obj) === '[object Date]' && (!toStringTag || !(
|
|
1204
|
+
return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1210
1205
|
}
|
|
1211
1206
|
|
|
1212
1207
|
function isRegExp(obj) {
|
|
1213
|
-
return toStr(obj) === '[object RegExp]' && (!toStringTag || !(
|
|
1208
|
+
return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1214
1209
|
}
|
|
1215
1210
|
|
|
1216
1211
|
function isError(obj) {
|
|
1217
|
-
return toStr(obj) === '[object Error]' && (!toStringTag || !(
|
|
1212
|
+
return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1218
1213
|
}
|
|
1219
1214
|
|
|
1220
1215
|
function isString(obj) {
|
|
1221
|
-
return toStr(obj) === '[object String]' && (!toStringTag || !(
|
|
1216
|
+
return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1222
1217
|
}
|
|
1223
1218
|
|
|
1224
1219
|
function isNumber(obj) {
|
|
1225
|
-
return toStr(obj) === '[object Number]' && (!toStringTag || !(
|
|
1220
|
+
return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1226
1221
|
}
|
|
1227
1222
|
|
|
1228
1223
|
function isBoolean(obj) {
|
|
1229
|
-
return toStr(obj) === '[object Boolean]' && (!toStringTag || !(
|
|
1224
|
+
return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
|
|
1230
1225
|
}
|
|
1231
1226
|
|
|
1232
1227
|
function isSymbol(obj) {
|
|
1233
1228
|
if (hasShammedSymbols) {
|
|
1234
|
-
return obj &&
|
|
1229
|
+
return obj && typeof obj === 'object' && obj instanceof Symbol;
|
|
1235
1230
|
}
|
|
1236
1231
|
|
|
1237
|
-
if (
|
|
1232
|
+
if (typeof obj === 'symbol') {
|
|
1238
1233
|
return true;
|
|
1239
1234
|
}
|
|
1240
1235
|
|
|
1241
|
-
if (!obj ||
|
|
1236
|
+
if (!obj || typeof obj !== 'object' || !symToString) {
|
|
1242
1237
|
return false;
|
|
1243
1238
|
}
|
|
1244
1239
|
|
|
@@ -1251,7 +1246,7 @@ function isSymbol(obj) {
|
|
|
1251
1246
|
}
|
|
1252
1247
|
|
|
1253
1248
|
function isBigInt(obj) {
|
|
1254
|
-
if (!obj ||
|
|
1249
|
+
if (!obj || typeof obj !== 'object' || !bigIntValueOf) {
|
|
1255
1250
|
return false;
|
|
1256
1251
|
}
|
|
1257
1252
|
|
|
@@ -1304,7 +1299,7 @@ function indexOf(xs, x) {
|
|
|
1304
1299
|
}
|
|
1305
1300
|
|
|
1306
1301
|
function isMap(x) {
|
|
1307
|
-
if (!mapSize || !x ||
|
|
1302
|
+
if (!mapSize || !x || typeof x !== 'object') {
|
|
1308
1303
|
return false;
|
|
1309
1304
|
}
|
|
1310
1305
|
|
|
@@ -1324,7 +1319,7 @@ function isMap(x) {
|
|
|
1324
1319
|
}
|
|
1325
1320
|
|
|
1326
1321
|
function isWeakMap(x) {
|
|
1327
|
-
if (!weakMapHas || !x ||
|
|
1322
|
+
if (!weakMapHas || !x || typeof x !== 'object') {
|
|
1328
1323
|
return false;
|
|
1329
1324
|
}
|
|
1330
1325
|
|
|
@@ -1344,7 +1339,7 @@ function isWeakMap(x) {
|
|
|
1344
1339
|
}
|
|
1345
1340
|
|
|
1346
1341
|
function isWeakRef(x) {
|
|
1347
|
-
if (!weakRefDeref || !x ||
|
|
1342
|
+
if (!weakRefDeref || !x || typeof x !== 'object') {
|
|
1348
1343
|
return false;
|
|
1349
1344
|
}
|
|
1350
1345
|
|
|
@@ -1357,7 +1352,7 @@ function isWeakRef(x) {
|
|
|
1357
1352
|
}
|
|
1358
1353
|
|
|
1359
1354
|
function isSet(x) {
|
|
1360
|
-
if (!setSize || !x ||
|
|
1355
|
+
if (!setSize || !x || typeof x !== 'object') {
|
|
1361
1356
|
return false;
|
|
1362
1357
|
}
|
|
1363
1358
|
|
|
@@ -1377,7 +1372,7 @@ function isSet(x) {
|
|
|
1377
1372
|
}
|
|
1378
1373
|
|
|
1379
1374
|
function isWeakSet(x) {
|
|
1380
|
-
if (!weakSetHas || !x ||
|
|
1375
|
+
if (!weakSetHas || !x || typeof x !== 'object') {
|
|
1381
1376
|
return false;
|
|
1382
1377
|
}
|
|
1383
1378
|
|
|
@@ -1397,7 +1392,7 @@ function isWeakSet(x) {
|
|
|
1397
1392
|
}
|
|
1398
1393
|
|
|
1399
1394
|
function isElement(x) {
|
|
1400
|
-
if (!x ||
|
|
1395
|
+
if (!x || typeof x !== 'object') {
|
|
1401
1396
|
return false;
|
|
1402
1397
|
}
|
|
1403
1398
|
|
|
@@ -1743,10 +1738,10 @@ var Format = {
|
|
|
1743
1738
|
module.exports = {
|
|
1744
1739
|
'default': Format.RFC3986,
|
|
1745
1740
|
formatters: {
|
|
1746
|
-
RFC1738: function
|
|
1741
|
+
RFC1738: function (value) {
|
|
1747
1742
|
return replace.call(value, percentTwenties, '+');
|
|
1748
1743
|
},
|
|
1749
|
-
RFC3986: function
|
|
1744
|
+
RFC3986: function (value) {
|
|
1750
1745
|
return String(value);
|
|
1751
1746
|
}
|
|
1752
1747
|
},
|
|
@@ -1795,13 +1790,13 @@ var defaults = {
|
|
|
1795
1790
|
strictNullHandling: false
|
|
1796
1791
|
};
|
|
1797
1792
|
|
|
1798
|
-
var interpretNumericEntities = function
|
|
1793
|
+
var interpretNumericEntities = function (str) {
|
|
1799
1794
|
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
|
|
1800
1795
|
return String.fromCharCode(parseInt(numberStr, 10));
|
|
1801
1796
|
});
|
|
1802
1797
|
};
|
|
1803
1798
|
|
|
1804
|
-
var parseArrayValue = function
|
|
1799
|
+
var parseArrayValue = function (val, options) {
|
|
1805
1800
|
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
|
|
1806
1801
|
return val.split(',');
|
|
1807
1802
|
}
|
|
@@ -1874,7 +1869,7 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
1874
1869
|
return obj;
|
|
1875
1870
|
};
|
|
1876
1871
|
|
|
1877
|
-
var parseObject = function
|
|
1872
|
+
var parseObject = function (chain, val, options, valuesParsed) {
|
|
1878
1873
|
var leaf = valuesParsed ? val : parseArrayValue(val, options);
|
|
1879
1874
|
|
|
1880
1875
|
for (var i = chain.length - 1; i >= 0; --i) {
|
|
@@ -2010,8 +2005,6 @@ module.exports = function (str, opts) {
|
|
|
2010
2005
|
},{"./utils":18}],17:[function(require,module,exports){
|
|
2011
2006
|
'use strict';
|
|
2012
2007
|
|
|
2013
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2014
|
-
|
|
2015
2008
|
var getSideChannel = require('side-channel');
|
|
2016
2009
|
|
|
2017
2010
|
var utils = require('./utils');
|
|
@@ -2035,7 +2028,7 @@ var isArray = Array.isArray;
|
|
|
2035
2028
|
var split = String.prototype.split;
|
|
2036
2029
|
var push = Array.prototype.push;
|
|
2037
2030
|
|
|
2038
|
-
var pushToArray = function
|
|
2031
|
+
var pushToArray = function (arr, valueOrArray) {
|
|
2039
2032
|
push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
|
2040
2033
|
};
|
|
2041
2034
|
|
|
@@ -2061,7 +2054,7 @@ var defaults = {
|
|
|
2061
2054
|
};
|
|
2062
2055
|
|
|
2063
2056
|
var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
|
|
2064
|
-
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' ||
|
|
2057
|
+
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || typeof v === 'symbol' || typeof v === 'bigint';
|
|
2065
2058
|
};
|
|
2066
2059
|
|
|
2067
2060
|
var sentinel = {};
|
|
@@ -2123,7 +2116,7 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
|
|
2123
2116
|
valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format));
|
|
2124
2117
|
}
|
|
2125
2118
|
|
|
2126
|
-
return [formatter(keyValue) + '=' + valuesJoined];
|
|
2119
|
+
return [formatter(keyValue) + (isArray(obj) && valuesArray.length === 1 ? '[]' : '') + '=' + valuesJoined];
|
|
2127
2120
|
}
|
|
2128
2121
|
|
|
2129
2122
|
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
|
|
@@ -2151,15 +2144,17 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
|
|
2151
2144
|
objKeys = sort ? keys.sort(sort) : keys;
|
|
2152
2145
|
}
|
|
2153
2146
|
|
|
2147
|
+
var adjustedPrefix = generateArrayPrefix === 'comma' && isArray(obj) && obj.length === 1 ? prefix + '[]' : prefix;
|
|
2148
|
+
|
|
2154
2149
|
for (var j = 0; j < objKeys.length; ++j) {
|
|
2155
2150
|
var key = objKeys[j];
|
|
2156
|
-
var value =
|
|
2151
|
+
var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
|
|
2157
2152
|
|
|
2158
2153
|
if (skipNulls && value === null) {
|
|
2159
2154
|
continue;
|
|
2160
2155
|
}
|
|
2161
2156
|
|
|
2162
|
-
var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(
|
|
2157
|
+
var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');
|
|
2163
2158
|
sideChannel.set(object, step);
|
|
2164
2159
|
var valueSideChannel = getSideChannel();
|
|
2165
2160
|
valueSideChannel.set(sentinel, sideChannel);
|
|
@@ -2236,7 +2231,7 @@ module.exports = function (object, opts) {
|
|
|
2236
2231
|
|
|
2237
2232
|
var keys = [];
|
|
2238
2233
|
|
|
2239
|
-
if (
|
|
2234
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
2240
2235
|
return '';
|
|
2241
2236
|
}
|
|
2242
2237
|
|
|
@@ -2289,8 +2284,6 @@ module.exports = function (object, opts) {
|
|
|
2289
2284
|
},{"./formats":14,"./utils":18,"side-channel":19}],18:[function(require,module,exports){
|
|
2290
2285
|
'use strict';
|
|
2291
2286
|
|
|
2292
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2293
|
-
|
|
2294
2287
|
var formats = require('./formats');
|
|
2295
2288
|
|
|
2296
2289
|
var has = Object.prototype.hasOwnProperty;
|
|
@@ -2342,10 +2335,10 @@ var merge = function merge(target, source, options) {
|
|
|
2342
2335
|
return target;
|
|
2343
2336
|
}
|
|
2344
2337
|
|
|
2345
|
-
if (
|
|
2338
|
+
if (typeof source !== 'object') {
|
|
2346
2339
|
if (isArray(target)) {
|
|
2347
2340
|
target.push(source);
|
|
2348
|
-
} else if (target &&
|
|
2341
|
+
} else if (target && typeof target === 'object') {
|
|
2349
2342
|
if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
|
|
2350
2343
|
target[source] = true;
|
|
2351
2344
|
}
|
|
@@ -2356,7 +2349,7 @@ var merge = function merge(target, source, options) {
|
|
|
2356
2349
|
return target;
|
|
2357
2350
|
}
|
|
2358
2351
|
|
|
2359
|
-
if (!target ||
|
|
2352
|
+
if (!target || typeof target !== 'object') {
|
|
2360
2353
|
return [target].concat(source);
|
|
2361
2354
|
}
|
|
2362
2355
|
|
|
@@ -2371,7 +2364,7 @@ var merge = function merge(target, source, options) {
|
|
|
2371
2364
|
if (has.call(target, i)) {
|
|
2372
2365
|
var targetItem = target[i];
|
|
2373
2366
|
|
|
2374
|
-
if (targetItem &&
|
|
2367
|
+
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
2375
2368
|
target[i] = merge(targetItem, item, options);
|
|
2376
2369
|
} else {
|
|
2377
2370
|
target.push(item);
|
|
@@ -2403,7 +2396,7 @@ var assign = function assignSingleSource(target, source) {
|
|
|
2403
2396
|
}, target);
|
|
2404
2397
|
};
|
|
2405
2398
|
|
|
2406
|
-
var decode = function
|
|
2399
|
+
var decode = function (str, decoder, charset) {
|
|
2407
2400
|
var strWithoutPlus = str.replace(/\+/g, ' ');
|
|
2408
2401
|
|
|
2409
2402
|
if (charset === 'iso-8859-1') {
|
|
@@ -2424,7 +2417,7 @@ var encode = function encode(str, defaultEncoder, charset, kind, format) {
|
|
|
2424
2417
|
|
|
2425
2418
|
var string = str;
|
|
2426
2419
|
|
|
2427
|
-
if (
|
|
2420
|
+
if (typeof str === 'symbol') {
|
|
2428
2421
|
string = Symbol.prototype.toString.call(str);
|
|
2429
2422
|
} else if (typeof str !== 'string') {
|
|
2430
2423
|
string = String(str);
|
|
@@ -2487,7 +2480,7 @@ var compact = function compact(value) {
|
|
|
2487
2480
|
var key = keys[j];
|
|
2488
2481
|
var val = obj[key];
|
|
2489
2482
|
|
|
2490
|
-
if (
|
|
2483
|
+
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
2491
2484
|
queue.push({
|
|
2492
2485
|
obj: obj,
|
|
2493
2486
|
prop: key
|
|
@@ -2506,7 +2499,7 @@ var isRegExp = function isRegExp(obj) {
|
|
|
2506
2499
|
};
|
|
2507
2500
|
|
|
2508
2501
|
var isBuffer = function isBuffer(obj) {
|
|
2509
|
-
if (!obj ||
|
|
2502
|
+
if (!obj || typeof obj !== 'object') {
|
|
2510
2503
|
return false;
|
|
2511
2504
|
}
|
|
2512
2505
|
|
|
@@ -2547,8 +2540,6 @@ module.exports = {
|
|
|
2547
2540
|
},{"./formats":14}],19:[function(require,module,exports){
|
|
2548
2541
|
'use strict';
|
|
2549
2542
|
|
|
2550
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2551
|
-
|
|
2552
2543
|
var GetIntrinsic = require('get-intrinsic');
|
|
2553
2544
|
|
|
2554
2545
|
var callBound = require('call-bind/callBound');
|
|
@@ -2565,7 +2556,7 @@ var $mapGet = callBound('Map.prototype.get', true);
|
|
|
2565
2556
|
var $mapSet = callBound('Map.prototype.set', true);
|
|
2566
2557
|
var $mapHas = callBound('Map.prototype.has', true);
|
|
2567
2558
|
|
|
2568
|
-
var listGetNode = function
|
|
2559
|
+
var listGetNode = function (list, key) {
|
|
2569
2560
|
for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
|
|
2570
2561
|
if (curr.key === key) {
|
|
2571
2562
|
prev.next = curr.next;
|
|
@@ -2576,12 +2567,12 @@ var listGetNode = function listGetNode(list, key) {
|
|
|
2576
2567
|
}
|
|
2577
2568
|
};
|
|
2578
2569
|
|
|
2579
|
-
var listGet = function
|
|
2570
|
+
var listGet = function (objects, key) {
|
|
2580
2571
|
var node = listGetNode(objects, key);
|
|
2581
2572
|
return node && node.value;
|
|
2582
2573
|
};
|
|
2583
2574
|
|
|
2584
|
-
var listSet = function
|
|
2575
|
+
var listSet = function (objects, key, value) {
|
|
2585
2576
|
var node = listGetNode(objects, key);
|
|
2586
2577
|
|
|
2587
2578
|
if (node) {
|
|
@@ -2595,7 +2586,7 @@ var listSet = function listSet(objects, key, value) {
|
|
|
2595
2586
|
}
|
|
2596
2587
|
};
|
|
2597
2588
|
|
|
2598
|
-
var listHas = function
|
|
2589
|
+
var listHas = function (objects, key) {
|
|
2599
2590
|
return !!listGetNode(objects, key);
|
|
2600
2591
|
};
|
|
2601
2592
|
|
|
@@ -2604,13 +2595,13 @@ module.exports = function getSideChannel() {
|
|
|
2604
2595
|
var $m;
|
|
2605
2596
|
var $o;
|
|
2606
2597
|
var channel = {
|
|
2607
|
-
assert: function
|
|
2598
|
+
assert: function (key) {
|
|
2608
2599
|
if (!channel.has(key)) {
|
|
2609
2600
|
throw new $TypeError('Side channel does not contain ' + inspect(key));
|
|
2610
2601
|
}
|
|
2611
2602
|
},
|
|
2612
|
-
get: function
|
|
2613
|
-
if ($WeakMap && key && (
|
|
2603
|
+
get: function (key) {
|
|
2604
|
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
|
2614
2605
|
if ($wm) {
|
|
2615
2606
|
return $weakMapGet($wm, key);
|
|
2616
2607
|
}
|
|
@@ -2624,8 +2615,8 @@ module.exports = function getSideChannel() {
|
|
|
2624
2615
|
}
|
|
2625
2616
|
}
|
|
2626
2617
|
},
|
|
2627
|
-
has: function
|
|
2628
|
-
if ($WeakMap && key && (
|
|
2618
|
+
has: function (key) {
|
|
2619
|
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
|
2629
2620
|
if ($wm) {
|
|
2630
2621
|
return $weakMapHas($wm, key);
|
|
2631
2622
|
}
|
|
@@ -2641,8 +2632,8 @@ module.exports = function getSideChannel() {
|
|
|
2641
2632
|
|
|
2642
2633
|
return false;
|
|
2643
2634
|
},
|
|
2644
|
-
set: function
|
|
2645
|
-
if ($WeakMap && key && (
|
|
2635
|
+
set: function (key, value) {
|
|
2636
|
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
|
2646
2637
|
if (!$wm) {
|
|
2647
2638
|
$wm = new $WeakMap();
|
|
2648
2639
|
}
|
|
@@ -2672,58 +2663,28 @@ module.exports = function getSideChannel() {
|
|
|
2672
2663
|
},{"call-bind/callBound":2,"get-intrinsic":8,"object-inspect":12}],20:[function(require,module,exports){
|
|
2673
2664
|
"use strict";
|
|
2674
2665
|
|
|
2675
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2676
|
-
|
|
2677
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
2678
|
-
|
|
2679
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
2680
|
-
|
|
2681
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
2682
|
-
|
|
2683
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2684
|
-
|
|
2685
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
2686
|
-
|
|
2687
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
2688
|
-
|
|
2689
2666
|
function Agent() {
|
|
2690
2667
|
this._defaults = [];
|
|
2691
2668
|
}
|
|
2692
2669
|
|
|
2693
|
-
|
|
2694
|
-
var fn = _arr[_i];
|
|
2695
|
-
|
|
2670
|
+
for (const fn of ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts']) {
|
|
2696
2671
|
Agent.prototype[fn] = function () {
|
|
2697
2672
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2698
2673
|
args[_key] = arguments[_key];
|
|
2699
2674
|
}
|
|
2700
2675
|
|
|
2701
2676
|
this._defaults.push({
|
|
2702
|
-
fn
|
|
2703
|
-
args
|
|
2677
|
+
fn,
|
|
2678
|
+
args
|
|
2704
2679
|
});
|
|
2705
2680
|
|
|
2706
2681
|
return this;
|
|
2707
2682
|
};
|
|
2708
|
-
};
|
|
2709
|
-
|
|
2710
|
-
for (var _i = 0, _arr = ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts']; _i < _arr.length; _i++) {
|
|
2711
|
-
_loop();
|
|
2712
2683
|
}
|
|
2713
2684
|
|
|
2714
2685
|
Agent.prototype._setDefaults = function (request) {
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
try {
|
|
2719
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2720
|
-
var def = _step.value;
|
|
2721
|
-
request[def.fn].apply(request, _toConsumableArray(def.args));
|
|
2722
|
-
}
|
|
2723
|
-
} catch (err) {
|
|
2724
|
-
_iterator.e(err);
|
|
2725
|
-
} finally {
|
|
2726
|
-
_iterator.f();
|
|
2686
|
+
for (const def of this._defaults) {
|
|
2687
|
+
request[def.fn](...def.args);
|
|
2727
2688
|
}
|
|
2728
2689
|
};
|
|
2729
2690
|
|
|
@@ -2732,15 +2693,7 @@ module.exports = Agent;
|
|
|
2732
2693
|
},{}],21:[function(require,module,exports){
|
|
2733
2694
|
"use strict";
|
|
2734
2695
|
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2738
|
-
|
|
2739
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
2740
|
-
|
|
2741
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
2742
|
-
|
|
2743
|
-
var root;
|
|
2696
|
+
let root;
|
|
2744
2697
|
|
|
2745
2698
|
if (typeof window !== 'undefined') {
|
|
2746
2699
|
root = window;
|
|
@@ -2751,22 +2704,23 @@ if (typeof window !== 'undefined') {
|
|
|
2751
2704
|
root = self;
|
|
2752
2705
|
}
|
|
2753
2706
|
|
|
2754
|
-
|
|
2707
|
+
const Emitter = require('component-emitter');
|
|
2755
2708
|
|
|
2756
|
-
|
|
2709
|
+
const safeStringify = require('fast-safe-stringify');
|
|
2757
2710
|
|
|
2758
|
-
|
|
2711
|
+
const qs = require('qs');
|
|
2759
2712
|
|
|
2760
|
-
|
|
2713
|
+
const RequestBase = require('./request-base');
|
|
2761
2714
|
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2715
|
+
const {
|
|
2716
|
+
isObject,
|
|
2717
|
+
mixin,
|
|
2718
|
+
hasOwn
|
|
2719
|
+
} = require('./utils');
|
|
2766
2720
|
|
|
2767
|
-
|
|
2721
|
+
const ResponseBase = require('./response-base');
|
|
2768
2722
|
|
|
2769
|
-
|
|
2723
|
+
const Agent = require('./agent-base');
|
|
2770
2724
|
|
|
2771
2725
|
function noop() {}
|
|
2772
2726
|
|
|
@@ -2783,44 +2737,24 @@ module.exports = function (method, url) {
|
|
|
2783
2737
|
};
|
|
2784
2738
|
|
|
2785
2739
|
exports = module.exports;
|
|
2786
|
-
|
|
2740
|
+
const request = exports;
|
|
2787
2741
|
exports.Request = Request;
|
|
2788
2742
|
|
|
2789
|
-
request.getXHR =
|
|
2790
|
-
if (root.XMLHttpRequest
|
|
2791
|
-
return new XMLHttpRequest();
|
|
2743
|
+
request.getXHR = () => {
|
|
2744
|
+
if (root.XMLHttpRequest) {
|
|
2745
|
+
return new root.XMLHttpRequest();
|
|
2792
2746
|
}
|
|
2793
2747
|
|
|
2794
|
-
try {
|
|
2795
|
-
return new ActiveXObject('Microsoft.XMLHTTP');
|
|
2796
|
-
} catch (_unused) {}
|
|
2797
|
-
|
|
2798
|
-
try {
|
|
2799
|
-
return new ActiveXObject('Msxml2.XMLHTTP.6.0');
|
|
2800
|
-
} catch (_unused2) {}
|
|
2801
|
-
|
|
2802
|
-
try {
|
|
2803
|
-
return new ActiveXObject('Msxml2.XMLHTTP.3.0');
|
|
2804
|
-
} catch (_unused3) {}
|
|
2805
|
-
|
|
2806
|
-
try {
|
|
2807
|
-
return new ActiveXObject('Msxml2.XMLHTTP');
|
|
2808
|
-
} catch (_unused4) {}
|
|
2809
|
-
|
|
2810
2748
|
throw new Error('Browser-only version of superagent could not find XHR');
|
|
2811
2749
|
};
|
|
2812
2750
|
|
|
2813
|
-
|
|
2814
|
-
return s.trim();
|
|
2815
|
-
} : function (s) {
|
|
2816
|
-
return s.replace(/(^\s*|\s*$)/g, '');
|
|
2817
|
-
};
|
|
2751
|
+
const trim = ''.trim ? s => s.trim() : s => s.replace(/(^\s*|\s*$)/g, '');
|
|
2818
2752
|
|
|
2819
2753
|
function serialize(object) {
|
|
2820
2754
|
if (!isObject(object)) return object;
|
|
2821
|
-
|
|
2755
|
+
const pairs = [];
|
|
2822
2756
|
|
|
2823
|
-
for (
|
|
2757
|
+
for (const key in object) {
|
|
2824
2758
|
if (hasOwn(object, key)) pushEncodedKeyValuePair(pairs, key, object[key]);
|
|
2825
2759
|
}
|
|
2826
2760
|
|
|
@@ -2836,21 +2770,11 @@ function pushEncodedKeyValuePair(pairs, key, value) {
|
|
|
2836
2770
|
}
|
|
2837
2771
|
|
|
2838
2772
|
if (Array.isArray(value)) {
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
try {
|
|
2843
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2844
|
-
var v = _step.value;
|
|
2845
|
-
pushEncodedKeyValuePair(pairs, key, v);
|
|
2846
|
-
}
|
|
2847
|
-
} catch (err) {
|
|
2848
|
-
_iterator.e(err);
|
|
2849
|
-
} finally {
|
|
2850
|
-
_iterator.f();
|
|
2773
|
+
for (const v of value) {
|
|
2774
|
+
pushEncodedKeyValuePair(pairs, key, v);
|
|
2851
2775
|
}
|
|
2852
2776
|
} else if (isObject(value)) {
|
|
2853
|
-
for (
|
|
2777
|
+
for (const subkey in value) {
|
|
2854
2778
|
if (hasOwn(value, subkey)) pushEncodedKeyValuePair(pairs, "".concat(key, "[").concat(subkey, "]"), value[subkey]);
|
|
2855
2779
|
}
|
|
2856
2780
|
} else {
|
|
@@ -2861,12 +2785,12 @@ function pushEncodedKeyValuePair(pairs, key, value) {
|
|
|
2861
2785
|
request.serializeObject = serialize;
|
|
2862
2786
|
|
|
2863
2787
|
function parseString(string_) {
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2788
|
+
const object = {};
|
|
2789
|
+
const pairs = string_.split('&');
|
|
2790
|
+
let pair;
|
|
2791
|
+
let pos;
|
|
2868
2792
|
|
|
2869
|
-
for (
|
|
2793
|
+
for (let i = 0, length_ = pairs.length; i < length_; ++i) {
|
|
2870
2794
|
pair = pairs[i];
|
|
2871
2795
|
pos = pair.indexOf('=');
|
|
2872
2796
|
|
|
@@ -2899,14 +2823,14 @@ request.parse = {
|
|
|
2899
2823
|
};
|
|
2900
2824
|
|
|
2901
2825
|
function parseHeader(string_) {
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
for (
|
|
2826
|
+
const lines = string_.split(/\r?\n/);
|
|
2827
|
+
const fields = {};
|
|
2828
|
+
let index;
|
|
2829
|
+
let line;
|
|
2830
|
+
let field;
|
|
2831
|
+
let value;
|
|
2832
|
+
|
|
2833
|
+
for (let i = 0, length_ = lines.length; i < length_; ++i) {
|
|
2910
2834
|
line = lines[i];
|
|
2911
2835
|
index = line.indexOf(':');
|
|
2912
2836
|
|
|
@@ -2931,7 +2855,9 @@ function Response(request_) {
|
|
|
2931
2855
|
this.xhr = this.req.xhr;
|
|
2932
2856
|
this.text = this.req.method !== 'HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text') || typeof this.xhr.responseType === 'undefined' ? this.xhr.responseText : null;
|
|
2933
2857
|
this.statusText = this.req.xhr.statusText;
|
|
2934
|
-
|
|
2858
|
+
let {
|
|
2859
|
+
status
|
|
2860
|
+
} = this.xhr;
|
|
2935
2861
|
|
|
2936
2862
|
if (status === 1223) {
|
|
2937
2863
|
status = 204;
|
|
@@ -2955,7 +2881,7 @@ function Response(request_) {
|
|
|
2955
2881
|
mixin(Response.prototype, ResponseBase.prototype);
|
|
2956
2882
|
|
|
2957
2883
|
Response.prototype._parseBody = function (string_) {
|
|
2958
|
-
|
|
2884
|
+
let parse = request.parse[this.type];
|
|
2959
2885
|
|
|
2960
2886
|
if (this.req._parser) {
|
|
2961
2887
|
return this.req._parser(this, string_);
|
|
@@ -2969,11 +2895,17 @@ Response.prototype._parseBody = function (string_) {
|
|
|
2969
2895
|
};
|
|
2970
2896
|
|
|
2971
2897
|
Response.prototype.toError = function () {
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2898
|
+
const {
|
|
2899
|
+
req
|
|
2900
|
+
} = this;
|
|
2901
|
+
const {
|
|
2902
|
+
method
|
|
2903
|
+
} = req;
|
|
2904
|
+
const {
|
|
2905
|
+
url
|
|
2906
|
+
} = req;
|
|
2907
|
+
const message = "cannot ".concat(method, " ").concat(url, " (").concat(this.status, ")");
|
|
2908
|
+
const error = new Error(message);
|
|
2977
2909
|
error.status = this.status;
|
|
2978
2910
|
error.method = method;
|
|
2979
2911
|
error.url = url;
|
|
@@ -2983,15 +2915,15 @@ Response.prototype.toError = function () {
|
|
|
2983
2915
|
request.Response = Response;
|
|
2984
2916
|
|
|
2985
2917
|
function Request(method, url) {
|
|
2986
|
-
|
|
2918
|
+
const self = this;
|
|
2987
2919
|
this._query = this._query || [];
|
|
2988
2920
|
this.method = method;
|
|
2989
2921
|
this.url = url;
|
|
2990
2922
|
this.header = {};
|
|
2991
2923
|
this._header = {};
|
|
2992
|
-
this.on('end',
|
|
2993
|
-
|
|
2994
|
-
|
|
2924
|
+
this.on('end', () => {
|
|
2925
|
+
let error = null;
|
|
2926
|
+
let res = null;
|
|
2995
2927
|
|
|
2996
2928
|
try {
|
|
2997
2929
|
res = new Response(self);
|
|
@@ -3013,7 +2945,7 @@ function Request(method, url) {
|
|
|
3013
2945
|
}
|
|
3014
2946
|
|
|
3015
2947
|
self.emit('response', res);
|
|
3016
|
-
|
|
2948
|
+
let new_error;
|
|
3017
2949
|
|
|
3018
2950
|
try {
|
|
3019
2951
|
if (!self._isResponseOK(res)) {
|
|
@@ -3026,7 +2958,7 @@ function Request(method, url) {
|
|
|
3026
2958
|
if (new_error) {
|
|
3027
2959
|
new_error.original = error;
|
|
3028
2960
|
new_error.response = res;
|
|
3029
|
-
new_error.status = res.status;
|
|
2961
|
+
new_error.status = new_error.status || res.status;
|
|
3030
2962
|
self.callback(new_error, res);
|
|
3031
2963
|
} else {
|
|
3032
2964
|
self.callback(null, res);
|
|
@@ -3050,7 +2982,7 @@ Request.prototype.accept = function (type) {
|
|
|
3050
2982
|
Request.prototype.auth = function (user, pass, options) {
|
|
3051
2983
|
if (arguments.length === 1) pass = '';
|
|
3052
2984
|
|
|
3053
|
-
if (
|
|
2985
|
+
if (typeof pass === 'object' && pass !== null) {
|
|
3054
2986
|
options = pass;
|
|
3055
2987
|
pass = '';
|
|
3056
2988
|
}
|
|
@@ -3061,7 +2993,7 @@ Request.prototype.auth = function (user, pass, options) {
|
|
|
3061
2993
|
};
|
|
3062
2994
|
}
|
|
3063
2995
|
|
|
3064
|
-
|
|
2996
|
+
const encoder = options.encoder ? options.encoder : string => {
|
|
3065
2997
|
if (typeof btoa === 'function') {
|
|
3066
2998
|
return btoa(string);
|
|
3067
2999
|
}
|
|
@@ -3102,7 +3034,7 @@ Request.prototype.callback = function (error, res) {
|
|
|
3102
3034
|
return this._retry();
|
|
3103
3035
|
}
|
|
3104
3036
|
|
|
3105
|
-
|
|
3037
|
+
const fn = this._callback;
|
|
3106
3038
|
this.clearTimeout();
|
|
3107
3039
|
|
|
3108
3040
|
if (error) {
|
|
@@ -3114,7 +3046,7 @@ Request.prototype.callback = function (error, res) {
|
|
|
3114
3046
|
};
|
|
3115
3047
|
|
|
3116
3048
|
Request.prototype.crossDomainError = function () {
|
|
3117
|
-
|
|
3049
|
+
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.');
|
|
3118
3050
|
error.crossDomain = true;
|
|
3119
3051
|
error.status = this.status;
|
|
3120
3052
|
error.method = this.method;
|
|
@@ -3130,14 +3062,14 @@ Request.prototype.agent = function () {
|
|
|
3130
3062
|
Request.prototype.ca = Request.prototype.agent;
|
|
3131
3063
|
Request.prototype.buffer = Request.prototype.ca;
|
|
3132
3064
|
|
|
3133
|
-
Request.prototype.write =
|
|
3065
|
+
Request.prototype.write = () => {
|
|
3134
3066
|
throw new Error('Streaming is not supported in browser version of superagent');
|
|
3135
3067
|
};
|
|
3136
3068
|
|
|
3137
3069
|
Request.prototype.pipe = Request.prototype.write;
|
|
3138
3070
|
|
|
3139
3071
|
Request.prototype._isHost = function (object) {
|
|
3140
|
-
return object &&
|
|
3072
|
+
return object && typeof object === 'object' && !Array.isArray(object) && Object.prototype.toString.call(object) !== '[object Object]';
|
|
3141
3073
|
};
|
|
3142
3074
|
|
|
3143
3075
|
Request.prototype.end = function (fn) {
|
|
@@ -3154,10 +3086,10 @@ Request.prototype.end = function (fn) {
|
|
|
3154
3086
|
};
|
|
3155
3087
|
|
|
3156
3088
|
Request.prototype._setUploadTimeout = function () {
|
|
3157
|
-
|
|
3089
|
+
const self = this;
|
|
3158
3090
|
|
|
3159
3091
|
if (this._uploadTimeout && !this._uploadTimeoutTimer) {
|
|
3160
|
-
this._uploadTimeoutTimer = setTimeout(
|
|
3092
|
+
this._uploadTimeoutTimer = setTimeout(() => {
|
|
3161
3093
|
self._timeoutError('Upload timeout of ', self._uploadTimeout, 'ETIMEDOUT');
|
|
3162
3094
|
}, this._uploadTimeout);
|
|
3163
3095
|
}
|
|
@@ -3165,15 +3097,19 @@ Request.prototype._setUploadTimeout = function () {
|
|
|
3165
3097
|
|
|
3166
3098
|
Request.prototype._end = function () {
|
|
3167
3099
|
if (this._aborted) return this.callback(new Error('The request has been aborted even before .end() was called'));
|
|
3168
|
-
|
|
3100
|
+
const self = this;
|
|
3169
3101
|
this.xhr = request.getXHR();
|
|
3170
|
-
|
|
3171
|
-
|
|
3102
|
+
const {
|
|
3103
|
+
xhr
|
|
3104
|
+
} = this;
|
|
3105
|
+
let data = this._formData || this._data;
|
|
3172
3106
|
|
|
3173
3107
|
this._setTimeouts();
|
|
3174
3108
|
|
|
3175
|
-
xhr.addEventListener('readystatechange',
|
|
3176
|
-
|
|
3109
|
+
xhr.addEventListener('readystatechange', () => {
|
|
3110
|
+
const {
|
|
3111
|
+
readyState
|
|
3112
|
+
} = xhr;
|
|
3177
3113
|
|
|
3178
3114
|
if (readyState >= 2 && self._responseTimeoutTimer) {
|
|
3179
3115
|
clearTimeout(self._responseTimeoutTimer);
|
|
@@ -3183,11 +3119,11 @@ Request.prototype._end = function () {
|
|
|
3183
3119
|
return;
|
|
3184
3120
|
}
|
|
3185
3121
|
|
|
3186
|
-
|
|
3122
|
+
let status;
|
|
3187
3123
|
|
|
3188
3124
|
try {
|
|
3189
3125
|
status = xhr.status;
|
|
3190
|
-
} catch (
|
|
3126
|
+
} catch (err) {
|
|
3191
3127
|
status = 0;
|
|
3192
3128
|
}
|
|
3193
3129
|
|
|
@@ -3199,7 +3135,7 @@ Request.prototype._end = function () {
|
|
|
3199
3135
|
self.emit('end');
|
|
3200
3136
|
});
|
|
3201
3137
|
|
|
3202
|
-
|
|
3138
|
+
const handleProgress = (direction, e) => {
|
|
3203
3139
|
if (e.total > 0) {
|
|
3204
3140
|
e.percent = e.loaded / e.total * 100;
|
|
3205
3141
|
|
|
@@ -3219,7 +3155,7 @@ Request.prototype._end = function () {
|
|
|
3219
3155
|
if (xhr.upload) {
|
|
3220
3156
|
xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload'));
|
|
3221
3157
|
}
|
|
3222
|
-
} catch (
|
|
3158
|
+
} catch (err) {}
|
|
3223
3159
|
}
|
|
3224
3160
|
|
|
3225
3161
|
if (xhr.upload) {
|
|
@@ -3239,18 +3175,17 @@ Request.prototype._end = function () {
|
|
|
3239
3175
|
if (this._withCredentials) xhr.withCredentials = true;
|
|
3240
3176
|
|
|
3241
3177
|
if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) {
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
var _serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
|
|
3178
|
+
const contentType = this._header['content-type'];
|
|
3179
|
+
let serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
|
|
3245
3180
|
|
|
3246
|
-
if (!
|
|
3247
|
-
|
|
3181
|
+
if (!serialize && isJSON(contentType)) {
|
|
3182
|
+
serialize = request.serialize['application/json'];
|
|
3248
3183
|
}
|
|
3249
3184
|
|
|
3250
|
-
if (
|
|
3185
|
+
if (serialize) data = serialize(data);
|
|
3251
3186
|
}
|
|
3252
3187
|
|
|
3253
|
-
for (
|
|
3188
|
+
for (const field in this.header) {
|
|
3254
3189
|
if (this.header[field] === null) continue;
|
|
3255
3190
|
if (hasOwn(this.header, field)) xhr.setRequestHeader(field, this.header[field]);
|
|
3256
3191
|
}
|
|
@@ -3263,15 +3198,11 @@ Request.prototype._end = function () {
|
|
|
3263
3198
|
xhr.send(typeof data === 'undefined' ? null : data);
|
|
3264
3199
|
};
|
|
3265
3200
|
|
|
3266
|
-
request.agent =
|
|
3267
|
-
return new Agent();
|
|
3268
|
-
};
|
|
3269
|
-
|
|
3270
|
-
var _loop = function _loop() {
|
|
3271
|
-
var method = _arr[_i];
|
|
3201
|
+
request.agent = () => new Agent();
|
|
3272
3202
|
|
|
3203
|
+
for (const method of ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE']) {
|
|
3273
3204
|
Agent.prototype[method.toLowerCase()] = function (url, fn) {
|
|
3274
|
-
|
|
3205
|
+
const request_ = new request.Request(method, url);
|
|
3275
3206
|
|
|
3276
3207
|
this._setDefaults(request_);
|
|
3277
3208
|
|
|
@@ -3281,16 +3212,12 @@ var _loop = function _loop() {
|
|
|
3281
3212
|
|
|
3282
3213
|
return request_;
|
|
3283
3214
|
};
|
|
3284
|
-
};
|
|
3285
|
-
|
|
3286
|
-
for (var _i = 0, _arr = ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE']; _i < _arr.length; _i++) {
|
|
3287
|
-
_loop();
|
|
3288
3215
|
}
|
|
3289
3216
|
|
|
3290
3217
|
Agent.prototype.del = Agent.prototype.delete;
|
|
3291
3218
|
|
|
3292
|
-
request.get =
|
|
3293
|
-
|
|
3219
|
+
request.get = (url, data, fn) => {
|
|
3220
|
+
const request_ = request('GET', url);
|
|
3294
3221
|
|
|
3295
3222
|
if (typeof data === 'function') {
|
|
3296
3223
|
fn = data;
|
|
@@ -3302,8 +3229,8 @@ request.get = function (url, data, fn) {
|
|
|
3302
3229
|
return request_;
|
|
3303
3230
|
};
|
|
3304
3231
|
|
|
3305
|
-
request.head =
|
|
3306
|
-
|
|
3232
|
+
request.head = (url, data, fn) => {
|
|
3233
|
+
const request_ = request('HEAD', url);
|
|
3307
3234
|
|
|
3308
3235
|
if (typeof data === 'function') {
|
|
3309
3236
|
fn = data;
|
|
@@ -3315,8 +3242,8 @@ request.head = function (url, data, fn) {
|
|
|
3315
3242
|
return request_;
|
|
3316
3243
|
};
|
|
3317
3244
|
|
|
3318
|
-
request.options =
|
|
3319
|
-
|
|
3245
|
+
request.options = (url, data, fn) => {
|
|
3246
|
+
const request_ = request('OPTIONS', url);
|
|
3320
3247
|
|
|
3321
3248
|
if (typeof data === 'function') {
|
|
3322
3249
|
fn = data;
|
|
@@ -3329,7 +3256,7 @@ request.options = function (url, data, fn) {
|
|
|
3329
3256
|
};
|
|
3330
3257
|
|
|
3331
3258
|
function del(url, data, fn) {
|
|
3332
|
-
|
|
3259
|
+
const request_ = request('DELETE', url);
|
|
3333
3260
|
|
|
3334
3261
|
if (typeof data === 'function') {
|
|
3335
3262
|
fn = data;
|
|
@@ -3344,8 +3271,8 @@ function del(url, data, fn) {
|
|
|
3344
3271
|
request.del = del;
|
|
3345
3272
|
request.delete = del;
|
|
3346
3273
|
|
|
3347
|
-
request.patch =
|
|
3348
|
-
|
|
3274
|
+
request.patch = (url, data, fn) => {
|
|
3275
|
+
const request_ = request('PATCH', url);
|
|
3349
3276
|
|
|
3350
3277
|
if (typeof data === 'function') {
|
|
3351
3278
|
fn = data;
|
|
@@ -3357,8 +3284,8 @@ request.patch = function (url, data, fn) {
|
|
|
3357
3284
|
return request_;
|
|
3358
3285
|
};
|
|
3359
3286
|
|
|
3360
|
-
request.post =
|
|
3361
|
-
|
|
3287
|
+
request.post = (url, data, fn) => {
|
|
3288
|
+
const request_ = request('POST', url);
|
|
3362
3289
|
|
|
3363
3290
|
if (typeof data === 'function') {
|
|
3364
3291
|
fn = data;
|
|
@@ -3370,8 +3297,8 @@ request.post = function (url, data, fn) {
|
|
|
3370
3297
|
return request_;
|
|
3371
3298
|
};
|
|
3372
3299
|
|
|
3373
|
-
request.put =
|
|
3374
|
-
|
|
3300
|
+
request.put = (url, data, fn) => {
|
|
3301
|
+
const request_ = request('PUT', url);
|
|
3375
3302
|
|
|
3376
3303
|
if (typeof data === 'function') {
|
|
3377
3304
|
fn = data;
|
|
@@ -3387,13 +3314,12 @@ request.put = function (url, data, fn) {
|
|
|
3387
3314
|
(function (process){(function (){
|
|
3388
3315
|
"use strict";
|
|
3389
3316
|
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
var semver = require('semver');
|
|
3317
|
+
const semver = require('semver');
|
|
3393
3318
|
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3319
|
+
const {
|
|
3320
|
+
isObject,
|
|
3321
|
+
hasOwn
|
|
3322
|
+
} = require('./utils');
|
|
3397
3323
|
|
|
3398
3324
|
module.exports = RequestBase;
|
|
3399
3325
|
|
|
@@ -3425,14 +3351,14 @@ RequestBase.prototype.serialize = function (fn) {
|
|
|
3425
3351
|
};
|
|
3426
3352
|
|
|
3427
3353
|
RequestBase.prototype.timeout = function (options) {
|
|
3428
|
-
if (!options ||
|
|
3354
|
+
if (!options || typeof options !== 'object') {
|
|
3429
3355
|
this._timeout = options;
|
|
3430
3356
|
this._responseTimeout = 0;
|
|
3431
3357
|
this._uploadTimeout = 0;
|
|
3432
3358
|
return this;
|
|
3433
3359
|
}
|
|
3434
3360
|
|
|
3435
|
-
for (
|
|
3361
|
+
for (const option in options) {
|
|
3436
3362
|
if (hasOwn(options, option)) {
|
|
3437
3363
|
switch (option) {
|
|
3438
3364
|
case 'deadline':
|
|
@@ -3465,8 +3391,8 @@ RequestBase.prototype.retry = function (count, fn) {
|
|
|
3465
3391
|
return this;
|
|
3466
3392
|
};
|
|
3467
3393
|
|
|
3468
|
-
|
|
3469
|
-
|
|
3394
|
+
const ERROR_CODES = new Set(['ETIMEDOUT', 'ECONNRESET', 'EADDRINUSE', 'ECONNREFUSED', 'EPIPE', 'ENOTFOUND', 'ENETUNREACH', 'EAI_AGAIN']);
|
|
3395
|
+
const STATUS_CODES = new Set([408, 413, 429, 500, 502, 503, 504, 521, 522, 524]);
|
|
3470
3396
|
|
|
3471
3397
|
RequestBase.prototype._shouldRetry = function (error, res) {
|
|
3472
3398
|
if (!this._maxRetries || this._retries++ >= this._maxRetries) {
|
|
@@ -3475,7 +3401,7 @@ RequestBase.prototype._shouldRetry = function (error, res) {
|
|
|
3475
3401
|
|
|
3476
3402
|
if (this._retryCallback) {
|
|
3477
3403
|
try {
|
|
3478
|
-
|
|
3404
|
+
const override = this._retryCallback(error, res);
|
|
3479
3405
|
|
|
3480
3406
|
if (override === true) return true;
|
|
3481
3407
|
if (override === false) return false;
|
|
@@ -3510,34 +3436,32 @@ RequestBase.prototype._retry = function () {
|
|
|
3510
3436
|
};
|
|
3511
3437
|
|
|
3512
3438
|
RequestBase.prototype.then = function (resolve, reject) {
|
|
3513
|
-
var _this = this;
|
|
3514
|
-
|
|
3515
3439
|
if (!this._fullfilledPromise) {
|
|
3516
|
-
|
|
3440
|
+
const self = this;
|
|
3517
3441
|
|
|
3518
3442
|
if (this._endCalled) {
|
|
3519
3443
|
console.warn('Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises');
|
|
3520
3444
|
}
|
|
3521
3445
|
|
|
3522
|
-
this._fullfilledPromise = new Promise(
|
|
3523
|
-
self.on('abort',
|
|
3524
|
-
if (
|
|
3446
|
+
this._fullfilledPromise = new Promise((resolve, reject) => {
|
|
3447
|
+
self.on('abort', () => {
|
|
3448
|
+
if (this._maxRetries && this._maxRetries > this._retries) {
|
|
3525
3449
|
return;
|
|
3526
3450
|
}
|
|
3527
3451
|
|
|
3528
|
-
if (
|
|
3529
|
-
reject(
|
|
3452
|
+
if (this.timedout && this.timedoutError) {
|
|
3453
|
+
reject(this.timedoutError);
|
|
3530
3454
|
return;
|
|
3531
3455
|
}
|
|
3532
3456
|
|
|
3533
|
-
|
|
3457
|
+
const error = new Error('Aborted');
|
|
3534
3458
|
error.code = 'ABORTED';
|
|
3535
|
-
error.status =
|
|
3536
|
-
error.method =
|
|
3537
|
-
error.url =
|
|
3459
|
+
error.status = this.status;
|
|
3460
|
+
error.method = this.method;
|
|
3461
|
+
error.url = this.url;
|
|
3538
3462
|
reject(error);
|
|
3539
3463
|
});
|
|
3540
|
-
self.end(
|
|
3464
|
+
self.end((error, res) => {
|
|
3541
3465
|
if (error) reject(error);else resolve(res);
|
|
3542
3466
|
});
|
|
3543
3467
|
});
|
|
@@ -3581,7 +3505,7 @@ RequestBase.prototype.getHeader = RequestBase.prototype.get;
|
|
|
3581
3505
|
|
|
3582
3506
|
RequestBase.prototype.set = function (field, value) {
|
|
3583
3507
|
if (isObject(field)) {
|
|
3584
|
-
for (
|
|
3508
|
+
for (const key in field) {
|
|
3585
3509
|
if (hasOwn(field, key)) this.set(key, field[key]);
|
|
3586
3510
|
}
|
|
3587
3511
|
|
|
@@ -3609,7 +3533,7 @@ RequestBase.prototype.field = function (name, value, options) {
|
|
|
3609
3533
|
}
|
|
3610
3534
|
|
|
3611
3535
|
if (isObject(name)) {
|
|
3612
|
-
for (
|
|
3536
|
+
for (const key in name) {
|
|
3613
3537
|
if (hasOwn(name, key)) this.field(key, name[key]);
|
|
3614
3538
|
}
|
|
3615
3539
|
|
|
@@ -3617,7 +3541,7 @@ RequestBase.prototype.field = function (name, value, options) {
|
|
|
3617
3541
|
}
|
|
3618
3542
|
|
|
3619
3543
|
if (Array.isArray(value)) {
|
|
3620
|
-
for (
|
|
3544
|
+
for (const i in value) {
|
|
3621
3545
|
if (hasOwn(value, i)) this.field(name, value[i]);
|
|
3622
3546
|
}
|
|
3623
3547
|
|
|
@@ -3711,8 +3635,8 @@ RequestBase.prototype.toJSON = function () {
|
|
|
3711
3635
|
};
|
|
3712
3636
|
|
|
3713
3637
|
RequestBase.prototype.send = function (data) {
|
|
3714
|
-
|
|
3715
|
-
|
|
3638
|
+
const isObject_ = isObject(data);
|
|
3639
|
+
let type = this._header['content-type'];
|
|
3716
3640
|
|
|
3717
3641
|
if (this._formData) {
|
|
3718
3642
|
throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");
|
|
@@ -3729,7 +3653,7 @@ RequestBase.prototype.send = function (data) {
|
|
|
3729
3653
|
}
|
|
3730
3654
|
|
|
3731
3655
|
if (isObject_ && isObject(this._data)) {
|
|
3732
|
-
for (
|
|
3656
|
+
for (const key in data) {
|
|
3733
3657
|
if (hasOwn(data, key)) this._data[key] = data[key];
|
|
3734
3658
|
}
|
|
3735
3659
|
} else if (typeof data === 'string') {
|
|
@@ -3760,7 +3684,7 @@ RequestBase.prototype.sortQuery = function (sort) {
|
|
|
3760
3684
|
};
|
|
3761
3685
|
|
|
3762
3686
|
RequestBase.prototype._finalizeQueryString = function () {
|
|
3763
|
-
|
|
3687
|
+
const query = this._query.join('&');
|
|
3764
3688
|
|
|
3765
3689
|
if (query) {
|
|
3766
3690
|
this.url += (this.url.includes('?') ? '&' : '?') + query;
|
|
@@ -3769,10 +3693,10 @@ RequestBase.prototype._finalizeQueryString = function () {
|
|
|
3769
3693
|
this._query.length = 0;
|
|
3770
3694
|
|
|
3771
3695
|
if (this._sort) {
|
|
3772
|
-
|
|
3696
|
+
const index = this.url.indexOf('?');
|
|
3773
3697
|
|
|
3774
3698
|
if (index >= 0) {
|
|
3775
|
-
|
|
3699
|
+
const queryArray = this.url.slice(index + 1).split('&');
|
|
3776
3700
|
|
|
3777
3701
|
if (typeof this._sort === 'function') {
|
|
3778
3702
|
queryArray.sort(this._sort);
|
|
@@ -3785,7 +3709,7 @@ RequestBase.prototype._finalizeQueryString = function () {
|
|
|
3785
3709
|
}
|
|
3786
3710
|
};
|
|
3787
3711
|
|
|
3788
|
-
RequestBase.prototype._appendQueryString =
|
|
3712
|
+
RequestBase.prototype._appendQueryString = () => {
|
|
3789
3713
|
console.warn('Unsupported');
|
|
3790
3714
|
};
|
|
3791
3715
|
|
|
@@ -3794,7 +3718,7 @@ RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
|
3794
3718
|
return;
|
|
3795
3719
|
}
|
|
3796
3720
|
|
|
3797
|
-
|
|
3721
|
+
const error = new Error("".concat(reason + timeout, "ms exceeded"));
|
|
3798
3722
|
error.timeout = timeout;
|
|
3799
3723
|
error.code = 'ECONNABORTED';
|
|
3800
3724
|
error.errno = errno;
|
|
@@ -3805,16 +3729,16 @@ RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
|
3805
3729
|
};
|
|
3806
3730
|
|
|
3807
3731
|
RequestBase.prototype._setTimeouts = function () {
|
|
3808
|
-
|
|
3732
|
+
const self = this;
|
|
3809
3733
|
|
|
3810
3734
|
if (this._timeout && !this._timer) {
|
|
3811
|
-
this._timer = setTimeout(
|
|
3735
|
+
this._timer = setTimeout(() => {
|
|
3812
3736
|
self._timeoutError('Timeout of ', self._timeout, 'ETIME');
|
|
3813
3737
|
}, this._timeout);
|
|
3814
3738
|
}
|
|
3815
3739
|
|
|
3816
3740
|
if (this._responseTimeout && !this._responseTimeoutTimer) {
|
|
3817
|
-
this._responseTimeoutTimer = setTimeout(
|
|
3741
|
+
this._responseTimeoutTimer = setTimeout(() => {
|
|
3818
3742
|
self._timeoutError('Response timeout of ', self._responseTimeout, 'ETIMEDOUT');
|
|
3819
3743
|
}, this._responseTimeout);
|
|
3820
3744
|
}
|
|
@@ -3824,7 +3748,7 @@ RequestBase.prototype._setTimeouts = function () {
|
|
|
3824
3748
|
},{"./utils":24,"_process":13,"semver":1}],23:[function(require,module,exports){
|
|
3825
3749
|
"use strict";
|
|
3826
3750
|
|
|
3827
|
-
|
|
3751
|
+
const utils = require('./utils');
|
|
3828
3752
|
|
|
3829
3753
|
module.exports = ResponseBase;
|
|
3830
3754
|
|
|
@@ -3835,11 +3759,11 @@ ResponseBase.prototype.get = function (field) {
|
|
|
3835
3759
|
};
|
|
3836
3760
|
|
|
3837
3761
|
ResponseBase.prototype._setHeaderProperties = function (header) {
|
|
3838
|
-
|
|
3762
|
+
const ct = header['content-type'] || '';
|
|
3839
3763
|
this.type = utils.type(ct);
|
|
3840
|
-
|
|
3764
|
+
const parameters = utils.params(ct);
|
|
3841
3765
|
|
|
3842
|
-
for (
|
|
3766
|
+
for (const key in parameters) {
|
|
3843
3767
|
if (Object.prototype.hasOwnProperty.call(parameters, key)) this[key] = parameters[key];
|
|
3844
3768
|
}
|
|
3845
3769
|
|
|
@@ -3849,11 +3773,11 @@ ResponseBase.prototype._setHeaderProperties = function (header) {
|
|
|
3849
3773
|
if (header.link) {
|
|
3850
3774
|
this.links = utils.parseLinks(header.link);
|
|
3851
3775
|
}
|
|
3852
|
-
} catch (
|
|
3776
|
+
} catch (err) {}
|
|
3853
3777
|
};
|
|
3854
3778
|
|
|
3855
3779
|
ResponseBase.prototype._setStatusProperties = function (status) {
|
|
3856
|
-
|
|
3780
|
+
const type = Math.trunc(status / 100);
|
|
3857
3781
|
this.statusCode = status;
|
|
3858
3782
|
this.status = this.statusCode;
|
|
3859
3783
|
this.statusType = type;
|
|
@@ -3877,67 +3801,35 @@ ResponseBase.prototype._setStatusProperties = function (status) {
|
|
|
3877
3801
|
},{"./utils":24}],24:[function(require,module,exports){
|
|
3878
3802
|
"use strict";
|
|
3879
3803
|
|
|
3880
|
-
|
|
3804
|
+
exports.type = string_ => string_.split(/ *; */).shift();
|
|
3881
3805
|
|
|
3882
|
-
|
|
3806
|
+
exports.params = value => {
|
|
3807
|
+
const object = {};
|
|
3883
3808
|
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
return string_.split(/ *; */).shift();
|
|
3890
|
-
};
|
|
3891
|
-
|
|
3892
|
-
exports.params = function (value) {
|
|
3893
|
-
var object = {};
|
|
3894
|
-
|
|
3895
|
-
var _iterator = _createForOfIteratorHelper(value.split(/ *; */)),
|
|
3896
|
-
_step;
|
|
3897
|
-
|
|
3898
|
-
try {
|
|
3899
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
3900
|
-
var string_ = _step.value;
|
|
3901
|
-
var parts = string_.split(/ *= */);
|
|
3902
|
-
var key = parts.shift();
|
|
3903
|
-
|
|
3904
|
-
var _value = parts.shift();
|
|
3905
|
-
|
|
3906
|
-
if (key && _value) object[key] = _value;
|
|
3907
|
-
}
|
|
3908
|
-
} catch (err) {
|
|
3909
|
-
_iterator.e(err);
|
|
3910
|
-
} finally {
|
|
3911
|
-
_iterator.f();
|
|
3809
|
+
for (const string_ of value.split(/ *; */)) {
|
|
3810
|
+
const parts = string_.split(/ *= */);
|
|
3811
|
+
const key = parts.shift();
|
|
3812
|
+
const value = parts.shift();
|
|
3813
|
+
if (key && value) object[key] = value;
|
|
3912
3814
|
}
|
|
3913
3815
|
|
|
3914
3816
|
return object;
|
|
3915
3817
|
};
|
|
3916
3818
|
|
|
3917
|
-
exports.parseLinks =
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
var _iterator2 = _createForOfIteratorHelper(value.split(/ *, */)),
|
|
3921
|
-
_step2;
|
|
3819
|
+
exports.parseLinks = value => {
|
|
3820
|
+
const object = {};
|
|
3922
3821
|
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
var rel = parts[1].split(/ *= */)[1].slice(1, -1);
|
|
3929
|
-
object[rel] = url;
|
|
3930
|
-
}
|
|
3931
|
-
} catch (err) {
|
|
3932
|
-
_iterator2.e(err);
|
|
3933
|
-
} finally {
|
|
3934
|
-
_iterator2.f();
|
|
3822
|
+
for (const string_ of value.split(/ *, */)) {
|
|
3823
|
+
const parts = string_.split(/ *; */);
|
|
3824
|
+
const url = parts[0].slice(1, -1);
|
|
3825
|
+
const rel = parts[1].split(/ *= */)[1].slice(1, -1);
|
|
3826
|
+
object[rel] = url;
|
|
3935
3827
|
}
|
|
3936
3828
|
|
|
3937
3829
|
return object;
|
|
3938
3830
|
};
|
|
3939
3831
|
|
|
3940
|
-
exports.cleanHeader =
|
|
3832
|
+
exports.cleanHeader = (header, changesOrigin) => {
|
|
3941
3833
|
delete header['content-type'];
|
|
3942
3834
|
delete header['content-length'];
|
|
3943
3835
|
delete header['transfer-encoding'];
|
|
@@ -3951,8 +3843,8 @@ exports.cleanHeader = function (header, changesOrigin) {
|
|
|
3951
3843
|
return header;
|
|
3952
3844
|
};
|
|
3953
3845
|
|
|
3954
|
-
exports.isObject =
|
|
3955
|
-
return object !== null &&
|
|
3846
|
+
exports.isObject = object => {
|
|
3847
|
+
return object !== null && typeof object === 'object';
|
|
3956
3848
|
};
|
|
3957
3849
|
|
|
3958
3850
|
exports.hasOwn = Object.hasOwn || function (object, property) {
|
|
@@ -3963,8 +3855,8 @@ exports.hasOwn = Object.hasOwn || function (object, property) {
|
|
|
3963
3855
|
return Object.prototype.hasOwnProperty.call(new Object(object), property);
|
|
3964
3856
|
};
|
|
3965
3857
|
|
|
3966
|
-
exports.mixin =
|
|
3967
|
-
for (
|
|
3858
|
+
exports.mixin = (target, source) => {
|
|
3859
|
+
for (const key in source) {
|
|
3968
3860
|
if (exports.hasOwn(source, key)) {
|
|
3969
3861
|
target[key] = source[key];
|
|
3970
3862
|
}
|