rekwest 3.1.1 → 3.2.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 +1 -1
- package/dist/index.js +8 -4
- package/package.json +9 -7
- package/src/index.mjs +3 -3
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ and [http2.request](https://nodejs.org/api/http2.html#http2_clienthttp2session_r
|
|
|
7
7
|
## Abstract
|
|
8
8
|
|
|
9
9
|
* Fetch-alike
|
|
10
|
-
* Cool-beans config options (with defaults)
|
|
10
|
+
* Cool-beans 🫐 config options (with defaults)
|
|
11
11
|
* Automatic HTTP/2 support (ALPN negotiation)
|
|
12
12
|
* Automatic or opt-in body parse (with non-UTF-8 charset decoding)
|
|
13
13
|
* Automatic and simplistic `Cookies` treatment (with built-in jar)
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.default = rekwest;
|
|
|
9
9
|
|
|
10
10
|
var _http = _interopRequireDefault(require("http"));
|
|
11
11
|
|
|
12
|
-
var _http2 =
|
|
12
|
+
var _http2 = _interopRequireWildcard(require("http2"));
|
|
13
13
|
|
|
14
14
|
exports.constants = _http2.constants;
|
|
15
15
|
|
|
@@ -73,6 +73,10 @@ Object.keys(_formdata).forEach(function (key) {
|
|
|
73
73
|
exports[key] = _formdata[key];
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
77
|
+
|
|
78
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
79
|
+
|
|
76
80
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
77
81
|
|
|
78
82
|
const {
|
|
@@ -199,14 +203,14 @@ async function rekwest(url, options = {}) {
|
|
|
199
203
|
|
|
200
204
|
if (follow && /^3\d{2}$/.test(res.statusCode) && res.headers[HTTP2_HEADER_LOCATION]) {
|
|
201
205
|
if (redirect === _helpers.redirects.error) {
|
|
202
|
-
res.emit('error', new _errors.RequestError(`Unexpected redirect, redirect mode is set to '${redirect}'.`));
|
|
206
|
+
return res.emit('error', new _errors.RequestError(`Unexpected redirect, redirect mode is set to '${redirect}'.`));
|
|
203
207
|
}
|
|
204
208
|
|
|
205
209
|
if (redirect === _helpers.redirects.follow) {
|
|
206
210
|
options.url = new URL(res.headers[HTTP2_HEADER_LOCATION], url).href;
|
|
207
211
|
|
|
208
212
|
if (res.statusCode !== HTTP_STATUS_SEE_OTHER && body === Object(body) && body.pipe?.constructor === Function) {
|
|
209
|
-
res.emit('error', new _errors.RequestError(`Unable to ${redirect} redirect with body
|
|
213
|
+
return res.emit('error', new _errors.RequestError(`Unable to ${redirect} redirect with streamable body.`));
|
|
210
214
|
}
|
|
211
215
|
|
|
212
216
|
options.follow--;
|
|
@@ -224,7 +228,7 @@ async function rekwest(url, options = {}) {
|
|
|
224
228
|
interval = Number(interval) * 1000 || new Date(interval) - Date.now();
|
|
225
229
|
|
|
226
230
|
if (interval > options.maxRetryAfter) {
|
|
227
|
-
res.emit('error', maxRetryAfterError(interval, {
|
|
231
|
+
return res.emit('error', maxRetryAfterError(interval, {
|
|
228
232
|
cause: (0, _helpers.mixin)(res, options)
|
|
229
233
|
}));
|
|
230
234
|
}
|
package/package.json
CHANGED
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@babel/cli": "^7.17.6",
|
|
12
|
-
"@babel/core": "^7.17.
|
|
12
|
+
"@babel/core": "^7.17.9",
|
|
13
13
|
"@babel/eslint-parser": "^7.17.0",
|
|
14
14
|
"@babel/preset-env": "^7.16.11",
|
|
15
|
-
"c8": "^7.11.
|
|
16
|
-
"eslint": "^8.
|
|
17
|
-
"eslint-config-ultra-refined": "^2.
|
|
18
|
-
"mocha": "^9.2.
|
|
15
|
+
"c8": "^7.11.2",
|
|
16
|
+
"eslint": "^8.14.0",
|
|
17
|
+
"eslint-config-ultra-refined": "^2.5.0",
|
|
18
|
+
"mocha": "^9.2.2"
|
|
19
19
|
},
|
|
20
20
|
"description": "The robust request library that humanity deserves 🌐",
|
|
21
21
|
"engines": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
],
|
|
32
32
|
"homepage": "https://github.com/bricss/rekwest#readme",
|
|
33
33
|
"keywords": [
|
|
34
|
+
"backoff",
|
|
34
35
|
"fetch",
|
|
35
36
|
"fetch-alike",
|
|
36
37
|
"formdata",
|
|
@@ -40,7 +41,8 @@
|
|
|
40
41
|
"h2c",
|
|
41
42
|
"http2",
|
|
42
43
|
"multipart",
|
|
43
|
-
"request"
|
|
44
|
+
"request",
|
|
45
|
+
"retry"
|
|
44
46
|
],
|
|
45
47
|
"license": "MIT",
|
|
46
48
|
"main": "./dist/index.js",
|
|
@@ -60,5 +62,5 @@
|
|
|
60
62
|
"test:bail": "mocha --bail",
|
|
61
63
|
"test:cover": "c8 --include=src --reporter=lcov --reporter=text npm test"
|
|
62
64
|
},
|
|
63
|
-
"version": "3.
|
|
65
|
+
"version": "3.2.0"
|
|
64
66
|
}
|
package/src/index.mjs
CHANGED
|
@@ -149,7 +149,7 @@ export default async function rekwest(url, options = {}) {
|
|
|
149
149
|
|
|
150
150
|
if (follow && /^3\d{2}$/.test(res.statusCode) && res.headers[HTTP2_HEADER_LOCATION]) {
|
|
151
151
|
if (redirect === redirects.error) {
|
|
152
|
-
res.emit('error', new RequestError(`Unexpected redirect, redirect mode is set to '${ redirect }'.`));
|
|
152
|
+
return res.emit('error', new RequestError(`Unexpected redirect, redirect mode is set to '${ redirect }'.`));
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
if (redirect === redirects.follow) {
|
|
@@ -157,7 +157,7 @@ export default async function rekwest(url, options = {}) {
|
|
|
157
157
|
|
|
158
158
|
if (res.statusCode !== HTTP_STATUS_SEE_OTHER
|
|
159
159
|
&& body === Object(body) && body.pipe?.constructor === Function) {
|
|
160
|
-
res.emit('error', new RequestError(`Unable to ${ redirect } redirect with body
|
|
160
|
+
return res.emit('error', new RequestError(`Unable to ${ redirect } redirect with streamable body.`));
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
options.follow--;
|
|
@@ -176,7 +176,7 @@ export default async function rekwest(url, options = {}) {
|
|
|
176
176
|
interval = Number(interval) * 1000 || new Date(interval) - Date.now();
|
|
177
177
|
|
|
178
178
|
if (interval > options.maxRetryAfter) {
|
|
179
|
-
res.emit('error', maxRetryAfterError(interval, { cause: mixin(res, options) }));
|
|
179
|
+
return res.emit('error', maxRetryAfterError(interval, { cause: mixin(res, options) }));
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
return setTimeoutPromise(interval).then(() => rekwest(options.url, options).then(resolve, reject));
|