superagent 8.0.3 → 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 -162
- package/lib/client.js +1 -1
- package/lib/node/http2wrapper.js +4 -2
- package/lib/node/index.js +3 -3
- package/lib/request-base.js +5 -4
- package/lib/response-base.js +1 -1
- 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,13 +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
2554
|
if (xhr.upload) {
|
|
2642
2555
|
this._setUploadTimeout();
|
|
2643
2556
|
}
|
|
2644
|
-
|
|
2645
2557
|
try {
|
|
2646
2558
|
if (this.username && this.password) {
|
|
2647
2559
|
xhr.open(this.method, this.url, true, this.username, this.password);
|
|
@@ -2651,9 +2563,7 @@ Request.prototype._end = function () {
|
|
|
2651
2563
|
} catch (err) {
|
|
2652
2564
|
return this.callback(err);
|
|
2653
2565
|
}
|
|
2654
|
-
|
|
2655
2566
|
if (this._withCredentials) xhr.withCredentials = true;
|
|
2656
|
-
|
|
2657
2567
|
if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) {
|
|
2658
2568
|
const contentType = this._header['content-type'];
|
|
2659
2569
|
let serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
|
|
@@ -2662,7 +2572,6 @@ Request.prototype._end = function () {
|
|
|
2662
2572
|
}
|
|
2663
2573
|
if (serialize) data = serialize(data);
|
|
2664
2574
|
}
|
|
2665
|
-
|
|
2666
2575
|
for (const field in this.header) {
|
|
2667
2576
|
if (this.header[field] === null) continue;
|
|
2668
2577
|
if (hasOwn(this.header, field)) xhr.setRequestHeader(field, this.header[field]);
|
|
@@ -2670,9 +2579,7 @@ Request.prototype._end = function () {
|
|
|
2670
2579
|
if (this._responseType) {
|
|
2671
2580
|
xhr.responseType = this._responseType;
|
|
2672
2581
|
}
|
|
2673
|
-
|
|
2674
2582
|
this.emit('request', this);
|
|
2675
|
-
|
|
2676
2583
|
xhr.send(typeof data === 'undefined' ? null : data);
|
|
2677
2584
|
};
|
|
2678
2585
|
request.agent = () => new Agent();
|
|
@@ -2687,7 +2594,6 @@ for (const method of ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE']) {
|
|
|
2687
2594
|
};
|
|
2688
2595
|
}
|
|
2689
2596
|
Agent.prototype.del = Agent.prototype.delete;
|
|
2690
|
-
|
|
2691
2597
|
request.get = (url, data, fn) => {
|
|
2692
2598
|
const request_ = request('GET', url);
|
|
2693
2599
|
if (typeof data === 'function') {
|
|
@@ -2698,7 +2604,6 @@ request.get = (url, data, fn) => {
|
|
|
2698
2604
|
if (fn) request_.end(fn);
|
|
2699
2605
|
return request_;
|
|
2700
2606
|
};
|
|
2701
|
-
|
|
2702
2607
|
request.head = (url, data, fn) => {
|
|
2703
2608
|
const request_ = request('HEAD', url);
|
|
2704
2609
|
if (typeof data === 'function') {
|
|
@@ -2709,7 +2614,6 @@ request.head = (url, data, fn) => {
|
|
|
2709
2614
|
if (fn) request_.end(fn);
|
|
2710
2615
|
return request_;
|
|
2711
2616
|
};
|
|
2712
|
-
|
|
2713
2617
|
request.options = (url, data, fn) => {
|
|
2714
2618
|
const request_ = request('OPTIONS', url);
|
|
2715
2619
|
if (typeof data === 'function') {
|
|
@@ -2720,7 +2624,6 @@ request.options = (url, data, fn) => {
|
|
|
2720
2624
|
if (fn) request_.end(fn);
|
|
2721
2625
|
return request_;
|
|
2722
2626
|
};
|
|
2723
|
-
|
|
2724
2627
|
function del(url, data, fn) {
|
|
2725
2628
|
const request_ = request('DELETE', url);
|
|
2726
2629
|
if (typeof data === 'function') {
|
|
@@ -2733,7 +2636,6 @@ function del(url, data, fn) {
|
|
|
2733
2636
|
}
|
|
2734
2637
|
request.del = del;
|
|
2735
2638
|
request.delete = del;
|
|
2736
|
-
|
|
2737
2639
|
request.patch = (url, data, fn) => {
|
|
2738
2640
|
const request_ = request('PATCH', url);
|
|
2739
2641
|
if (typeof data === 'function') {
|
|
@@ -2744,7 +2646,6 @@ request.patch = (url, data, fn) => {
|
|
|
2744
2646
|
if (fn) request_.end(fn);
|
|
2745
2647
|
return request_;
|
|
2746
2648
|
};
|
|
2747
|
-
|
|
2748
2649
|
request.post = (url, data, fn) => {
|
|
2749
2650
|
const request_ = request('POST', url);
|
|
2750
2651
|
if (typeof data === 'function') {
|
|
@@ -2755,7 +2656,6 @@ request.post = (url, data, fn) => {
|
|
|
2755
2656
|
if (fn) request_.end(fn);
|
|
2756
2657
|
return request_;
|
|
2757
2658
|
};
|
|
2758
|
-
|
|
2759
2659
|
request.put = (url, data, fn) => {
|
|
2760
2660
|
const request_ = request('PUT', url);
|
|
2761
2661
|
if (typeof data === 'function') {
|
|
@@ -2770,16 +2670,12 @@ request.put = (url, data, fn) => {
|
|
|
2770
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){
|
|
2771
2671
|
(function (process){(function (){
|
|
2772
2672
|
const semver = require('semver');
|
|
2773
|
-
|
|
2774
2673
|
const {
|
|
2775
2674
|
isObject,
|
|
2776
2675
|
hasOwn
|
|
2777
2676
|
} = require('./utils');
|
|
2778
|
-
|
|
2779
2677
|
module.exports = RequestBase;
|
|
2780
|
-
|
|
2781
2678
|
function RequestBase() {}
|
|
2782
|
-
|
|
2783
2679
|
RequestBase.prototype.clearTimeout = function () {
|
|
2784
2680
|
clearTimeout(this._timer);
|
|
2785
2681
|
clearTimeout(this._responseTimeoutTimer);
|
|
@@ -2789,22 +2685,18 @@ RequestBase.prototype.clearTimeout = function () {
|
|
|
2789
2685
|
delete this._uploadTimeoutTimer;
|
|
2790
2686
|
return this;
|
|
2791
2687
|
};
|
|
2792
|
-
|
|
2793
2688
|
RequestBase.prototype.parse = function (fn) {
|
|
2794
2689
|
this._parser = fn;
|
|
2795
2690
|
return this;
|
|
2796
2691
|
};
|
|
2797
|
-
|
|
2798
2692
|
RequestBase.prototype.responseType = function (value) {
|
|
2799
2693
|
this._responseType = value;
|
|
2800
2694
|
return this;
|
|
2801
2695
|
};
|
|
2802
|
-
|
|
2803
2696
|
RequestBase.prototype.serialize = function (fn) {
|
|
2804
2697
|
this._serializer = fn;
|
|
2805
2698
|
return this;
|
|
2806
2699
|
};
|
|
2807
|
-
|
|
2808
2700
|
RequestBase.prototype.timeout = function (options) {
|
|
2809
2701
|
if (!options || typeof options !== 'object') {
|
|
2810
2702
|
this._timeout = options;
|
|
@@ -2831,7 +2723,6 @@ RequestBase.prototype.timeout = function (options) {
|
|
|
2831
2723
|
}
|
|
2832
2724
|
return this;
|
|
2833
2725
|
};
|
|
2834
|
-
|
|
2835
2726
|
RequestBase.prototype.retry = function (count, fn) {
|
|
2836
2727
|
if (arguments.length === 0 || count === true) count = 1;
|
|
2837
2728
|
if (count <= 0) count = 0;
|
|
@@ -2840,10 +2731,8 @@ RequestBase.prototype.retry = function (count, fn) {
|
|
|
2840
2731
|
this._retryCallback = fn;
|
|
2841
2732
|
return this;
|
|
2842
2733
|
};
|
|
2843
|
-
|
|
2844
2734
|
const ERROR_CODES = new Set(['ETIMEDOUT', 'ECONNRESET', 'EADDRINUSE', 'ECONNREFUSED', 'EPIPE', 'ENOTFOUND', 'ENETUNREACH', 'EAI_AGAIN']);
|
|
2845
2735
|
const STATUS_CODES = new Set([408, 413, 429, 500, 502, 503, 504, 521, 522, 524]);
|
|
2846
|
-
|
|
2847
2736
|
RequestBase.prototype._shouldRetry = function (error, res) {
|
|
2848
2737
|
if (!this._maxRetries || this._retries++ >= this._maxRetries) {
|
|
2849
2738
|
return false;
|
|
@@ -2857,7 +2746,6 @@ RequestBase.prototype._shouldRetry = function (error, res) {
|
|
|
2857
2746
|
console.error(err);
|
|
2858
2747
|
}
|
|
2859
2748
|
}
|
|
2860
|
-
|
|
2861
2749
|
if (res && res.status && STATUS_CODES.has(res.status)) return true;
|
|
2862
2750
|
if (error) {
|
|
2863
2751
|
if (error.code && ERROR_CODES.has(error.code)) return true;
|
|
@@ -2866,10 +2754,8 @@ RequestBase.prototype._shouldRetry = function (error, res) {
|
|
|
2866
2754
|
}
|
|
2867
2755
|
return false;
|
|
2868
2756
|
};
|
|
2869
|
-
|
|
2870
2757
|
RequestBase.prototype._retry = function () {
|
|
2871
2758
|
this.clearTimeout();
|
|
2872
|
-
|
|
2873
2759
|
if (this.req) {
|
|
2874
2760
|
this.req = null;
|
|
2875
2761
|
this.req = this.request();
|
|
@@ -2879,7 +2765,6 @@ RequestBase.prototype._retry = function () {
|
|
|
2879
2765
|
this.timedoutError = null;
|
|
2880
2766
|
return this._end();
|
|
2881
2767
|
};
|
|
2882
|
-
|
|
2883
2768
|
RequestBase.prototype.then = function (resolve, reject) {
|
|
2884
2769
|
if (!this._fullfilledPromise) {
|
|
2885
2770
|
const self = this;
|
|
@@ -2912,7 +2797,6 @@ RequestBase.prototype.then = function (resolve, reject) {
|
|
|
2912
2797
|
RequestBase.prototype.catch = function (callback) {
|
|
2913
2798
|
return this.then(undefined, callback);
|
|
2914
2799
|
};
|
|
2915
|
-
|
|
2916
2800
|
RequestBase.prototype.use = function (fn) {
|
|
2917
2801
|
fn(this);
|
|
2918
2802
|
return this;
|
|
@@ -2931,13 +2815,10 @@ RequestBase.prototype._isResponseOK = function (res) {
|
|
|
2931
2815
|
}
|
|
2932
2816
|
return res.status >= 200 && res.status < 300;
|
|
2933
2817
|
};
|
|
2934
|
-
|
|
2935
2818
|
RequestBase.prototype.get = function (field) {
|
|
2936
2819
|
return this._header[field.toLowerCase()];
|
|
2937
2820
|
};
|
|
2938
|
-
|
|
2939
2821
|
RequestBase.prototype.getHeader = RequestBase.prototype.get;
|
|
2940
|
-
|
|
2941
2822
|
RequestBase.prototype.set = function (field, value) {
|
|
2942
2823
|
if (isObject(field)) {
|
|
2943
2824
|
for (const key in field) {
|
|
@@ -2949,13 +2830,11 @@ RequestBase.prototype.set = function (field, value) {
|
|
|
2949
2830
|
this.header[field] = value;
|
|
2950
2831
|
return this;
|
|
2951
2832
|
};
|
|
2952
|
-
|
|
2953
2833
|
RequestBase.prototype.unset = function (field) {
|
|
2954
2834
|
delete this._header[field.toLowerCase()];
|
|
2955
2835
|
delete this.header[field];
|
|
2956
2836
|
return this;
|
|
2957
2837
|
};
|
|
2958
|
-
|
|
2959
2838
|
RequestBase.prototype.field = function (name, value, options) {
|
|
2960
2839
|
if (name === null || undefined === name) {
|
|
2961
2840
|
throw new Error('.field(name, val) name can not be empty');
|
|
@@ -2975,18 +2854,15 @@ RequestBase.prototype.field = function (name, value, options) {
|
|
|
2975
2854
|
}
|
|
2976
2855
|
return this;
|
|
2977
2856
|
}
|
|
2978
|
-
|
|
2979
2857
|
if (value === null || undefined === value) {
|
|
2980
2858
|
throw new Error('.field(name, val) val can not be empty');
|
|
2981
2859
|
}
|
|
2982
2860
|
if (typeof value === 'boolean') {
|
|
2983
2861
|
value = String(value);
|
|
2984
2862
|
}
|
|
2985
|
-
|
|
2986
2863
|
if (options) this._getFormData().append(name, value, options);else this._getFormData().append(name, value);
|
|
2987
2864
|
return this;
|
|
2988
2865
|
};
|
|
2989
|
-
|
|
2990
2866
|
RequestBase.prototype.abort = function () {
|
|
2991
2867
|
if (this._aborted) {
|
|
2992
2868
|
return this;
|
|
@@ -3001,7 +2877,6 @@ RequestBase.prototype.abort = function () {
|
|
|
3001
2877
|
}
|
|
3002
2878
|
this.req.abort();
|
|
3003
2879
|
}
|
|
3004
|
-
|
|
3005
2880
|
this.clearTimeout();
|
|
3006
2881
|
this.emit('abort');
|
|
3007
2882
|
return this;
|
|
@@ -3023,18 +2898,15 @@ RequestBase.prototype._auth = function (user, pass, options, base64Encoder) {
|
|
|
3023
2898
|
}
|
|
3024
2899
|
return this;
|
|
3025
2900
|
};
|
|
3026
|
-
|
|
3027
2901
|
RequestBase.prototype.withCredentials = function (on) {
|
|
3028
2902
|
if (on === undefined) on = true;
|
|
3029
2903
|
this._withCredentials = on;
|
|
3030
2904
|
return this;
|
|
3031
2905
|
};
|
|
3032
|
-
|
|
3033
2906
|
RequestBase.prototype.redirects = function (n) {
|
|
3034
2907
|
this._maxRedirects = n;
|
|
3035
2908
|
return this;
|
|
3036
2909
|
};
|
|
3037
|
-
|
|
3038
2910
|
RequestBase.prototype.maxResponseSize = function (n) {
|
|
3039
2911
|
if (typeof n !== 'number') {
|
|
3040
2912
|
throw new TypeError('Invalid argument');
|
|
@@ -3042,7 +2914,6 @@ RequestBase.prototype.maxResponseSize = function (n) {
|
|
|
3042
2914
|
this._maxResponseSize = n;
|
|
3043
2915
|
return this;
|
|
3044
2916
|
};
|
|
3045
|
-
|
|
3046
2917
|
RequestBase.prototype.toJSON = function () {
|
|
3047
2918
|
return {
|
|
3048
2919
|
method: this.method,
|
|
@@ -3051,7 +2922,6 @@ RequestBase.prototype.toJSON = function () {
|
|
|
3051
2922
|
headers: this._header
|
|
3052
2923
|
};
|
|
3053
2924
|
};
|
|
3054
|
-
|
|
3055
2925
|
RequestBase.prototype.send = function (data) {
|
|
3056
2926
|
const isObject_ = isObject(data);
|
|
3057
2927
|
let type = this._header['content-type'];
|
|
@@ -3067,7 +2937,6 @@ RequestBase.prototype.send = function (data) {
|
|
|
3067
2937
|
} else if (data && this._data && this._isHost(this._data)) {
|
|
3068
2938
|
throw new Error("Can't merge these send calls");
|
|
3069
2939
|
}
|
|
3070
|
-
|
|
3071
2940
|
if (isObject_ && isObject(this._data)) {
|
|
3072
2941
|
for (const key in data) {
|
|
3073
2942
|
if (hasOwn(data, key)) this._data[key] = data[key];
|
|
@@ -3087,23 +2956,19 @@ RequestBase.prototype.send = function (data) {
|
|
|
3087
2956
|
if (!isObject_ || this._isHost(data)) {
|
|
3088
2957
|
return this;
|
|
3089
2958
|
}
|
|
3090
|
-
|
|
3091
2959
|
if (!type) this.type('json');
|
|
3092
2960
|
return this;
|
|
3093
2961
|
};
|
|
3094
|
-
|
|
3095
2962
|
RequestBase.prototype.sortQuery = function (sort) {
|
|
3096
2963
|
this._sort = typeof sort === 'undefined' ? true : sort;
|
|
3097
2964
|
return this;
|
|
3098
2965
|
};
|
|
3099
|
-
|
|
3100
2966
|
RequestBase.prototype._finalizeQueryString = function () {
|
|
3101
2967
|
const query = this._query.join('&');
|
|
3102
2968
|
if (query) {
|
|
3103
2969
|
this.url += (this.url.includes('?') ? '&' : '?') + query;
|
|
3104
2970
|
}
|
|
3105
2971
|
this._query.length = 0;
|
|
3106
|
-
|
|
3107
2972
|
if (this._sort) {
|
|
3108
2973
|
const index = this.url.indexOf('?');
|
|
3109
2974
|
if (index >= 0) {
|
|
@@ -3117,11 +2982,9 @@ RequestBase.prototype._finalizeQueryString = function () {
|
|
|
3117
2982
|
}
|
|
3118
2983
|
}
|
|
3119
2984
|
};
|
|
3120
|
-
|
|
3121
2985
|
RequestBase.prototype._appendQueryString = () => {
|
|
3122
2986
|
console.warn('Unsupported');
|
|
3123
2987
|
};
|
|
3124
|
-
|
|
3125
2988
|
RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
3126
2989
|
if (this._aborted) {
|
|
3127
2990
|
return;
|
|
@@ -3137,13 +3000,11 @@ RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
|
|
|
3137
3000
|
};
|
|
3138
3001
|
RequestBase.prototype._setTimeouts = function () {
|
|
3139
3002
|
const self = this;
|
|
3140
|
-
|
|
3141
3003
|
if (this._timeout && !this._timer) {
|
|
3142
3004
|
this._timer = setTimeout(() => {
|
|
3143
3005
|
self._timeoutError('Timeout of ', self._timeout, 'ETIME');
|
|
3144
3006
|
}, this._timeout);
|
|
3145
3007
|
}
|
|
3146
|
-
|
|
3147
3008
|
if (this._responseTimeout && !this._responseTimeoutTimer) {
|
|
3148
3009
|
this._responseTimeoutTimer = setTimeout(() => {
|
|
3149
3010
|
self._timeoutError('Response timeout of ', self._responseTimeout, 'ETIMEDOUT');
|
|
@@ -3153,51 +3014,37 @@ RequestBase.prototype._setTimeouts = function () {
|
|
|
3153
3014
|
|
|
3154
3015
|
}).call(this)}).call(this,require('_process'))
|
|
3155
3016
|
},{"./utils":24,"_process":13,"semver":1}],23:[function(require,module,exports){
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
3017
|
const utils = require('./utils');
|
|
3159
|
-
|
|
3160
3018
|
module.exports = ResponseBase;
|
|
3161
|
-
|
|
3162
3019
|
function ResponseBase() {}
|
|
3163
|
-
|
|
3164
3020
|
ResponseBase.prototype.get = function (field) {
|
|
3165
3021
|
return this.header[field.toLowerCase()];
|
|
3166
3022
|
};
|
|
3167
|
-
|
|
3168
3023
|
ResponseBase.prototype._setHeaderProperties = function (header) {
|
|
3169
|
-
|
|
3170
3024
|
const ct = header['content-type'] || '';
|
|
3171
3025
|
this.type = utils.type(ct);
|
|
3172
|
-
|
|
3173
3026
|
const parameters = utils.params(ct);
|
|
3174
3027
|
for (const key in parameters) {
|
|
3175
3028
|
if (Object.prototype.hasOwnProperty.call(parameters, key)) this[key] = parameters[key];
|
|
3176
3029
|
}
|
|
3177
3030
|
this.links = {};
|
|
3178
|
-
|
|
3179
3031
|
try {
|
|
3180
3032
|
if (header.link) {
|
|
3181
3033
|
this.links = utils.parseLinks(header.link);
|
|
3182
3034
|
}
|
|
3183
|
-
} catch (err) {
|
|
3184
|
-
}
|
|
3035
|
+
} catch (err) {}
|
|
3185
3036
|
};
|
|
3186
|
-
|
|
3187
3037
|
ResponseBase.prototype._setStatusProperties = function (status) {
|
|
3188
3038
|
const type = Math.trunc(status / 100);
|
|
3189
|
-
|
|
3190
3039
|
this.statusCode = status;
|
|
3191
3040
|
this.status = this.statusCode;
|
|
3192
3041
|
this.statusType = type;
|
|
3193
|
-
|
|
3194
3042
|
this.info = type === 1;
|
|
3195
3043
|
this.ok = type === 2;
|
|
3196
3044
|
this.redirect = type === 3;
|
|
3197
3045
|
this.clientError = type === 4;
|
|
3198
3046
|
this.serverError = type === 5;
|
|
3199
3047
|
this.error = type === 4 || type === 5 ? this.toError() : false;
|
|
3200
|
-
|
|
3201
3048
|
this.created = status === 201;
|
|
3202
3049
|
this.accepted = status === 202;
|
|
3203
3050
|
this.noContent = status === 204;
|
|
@@ -3210,10 +3057,7 @@ ResponseBase.prototype._setStatusProperties = function (status) {
|
|
|
3210
3057
|
};
|
|
3211
3058
|
|
|
3212
3059
|
},{"./utils":24}],24:[function(require,module,exports){
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
3060
|
exports.type = string_ => string_.split(/ *; */).shift();
|
|
3216
|
-
|
|
3217
3061
|
exports.params = value => {
|
|
3218
3062
|
const object = {};
|
|
3219
3063
|
for (const string_ of value.split(/ *; */)) {
|
|
@@ -3224,7 +3068,6 @@ exports.params = value => {
|
|
|
3224
3068
|
}
|
|
3225
3069
|
return object;
|
|
3226
3070
|
};
|
|
3227
|
-
|
|
3228
3071
|
exports.parseLinks = value => {
|
|
3229
3072
|
const object = {};
|
|
3230
3073
|
for (const string_ of value.split(/ *, */)) {
|
|
@@ -3235,7 +3078,6 @@ exports.parseLinks = value => {
|
|
|
3235
3078
|
}
|
|
3236
3079
|
return object;
|
|
3237
3080
|
};
|
|
3238
|
-
|
|
3239
3081
|
exports.cleanHeader = (header, changesOrigin) => {
|
|
3240
3082
|
delete header['content-type'];
|
|
3241
3083
|
delete header['content-length'];
|
|
@@ -3247,11 +3089,9 @@ exports.cleanHeader = (header, changesOrigin) => {
|
|
|
3247
3089
|
}
|
|
3248
3090
|
return header;
|
|
3249
3091
|
};
|
|
3250
|
-
|
|
3251
3092
|
exports.isObject = object => {
|
|
3252
3093
|
return object !== null && typeof object === 'object';
|
|
3253
3094
|
};
|
|
3254
|
-
|
|
3255
3095
|
exports.hasOwn = Object.hasOwn || function (object, property) {
|
|
3256
3096
|
if (object == null) {
|
|
3257
3097
|
throw new TypeError('Cannot convert undefined or null to object');
|