rezo 1.0.11 → 1.0.13
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/dist/adapters/curl.cjs +73 -10
- package/dist/adapters/curl.js +73 -10
- package/dist/adapters/entries/curl.d.ts +66 -1
- package/dist/adapters/entries/fetch.d.ts +66 -1
- package/dist/adapters/entries/http.d.ts +66 -1
- package/dist/adapters/entries/http2.d.ts +66 -1
- package/dist/adapters/entries/react-native.d.ts +66 -1
- package/dist/adapters/entries/xhr.d.ts +66 -1
- package/dist/adapters/fetch.cjs +106 -59
- package/dist/adapters/fetch.js +106 -59
- package/dist/adapters/http.cjs +28 -15
- package/dist/adapters/http.js +28 -15
- package/dist/adapters/http2.cjs +114 -55
- package/dist/adapters/http2.js +114 -55
- package/dist/adapters/index.cjs +6 -6
- package/dist/cache/index.cjs +13 -13
- package/dist/crawler.d.ts +66 -1
- package/dist/entries/crawler.cjs +5 -5
- package/dist/index.cjs +24 -24
- package/dist/index.d.ts +66 -1
- package/dist/platform/browser.d.ts +66 -1
- package/dist/platform/bun.d.ts +66 -1
- package/dist/platform/deno.d.ts +66 -1
- package/dist/platform/node.d.ts +66 -1
- package/dist/platform/react-native.d.ts +66 -1
- package/dist/platform/worker.d.ts +66 -1
- package/dist/plugin/index.cjs +36 -36
- package/dist/proxy/index.cjs +2 -2
- package/dist/queue/index.cjs +8 -8
- package/dist/responses/buildError.cjs +5 -1
- package/dist/responses/buildError.js +5 -1
- package/dist/responses/buildResponse.cjs +30 -3
- package/dist/responses/buildResponse.js +30 -3
- package/dist/utils/compression.cjs +6 -6
- package/dist/utils/compression.js +6 -6
- package/dist/utils/headers.cjs +17 -0
- package/dist/utils/headers.js +17 -1
- package/dist/utils/http-config.cjs +47 -5
- package/dist/utils/http-config.js +47 -5
- package/package.json +1 -1
package/dist/utils/headers.cjs
CHANGED
|
@@ -156,7 +156,24 @@ class RezoHeaders extends Headers {
|
|
|
156
156
|
return "RezoHeaders";
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
+
function sanitizeHttp2Headers(headers) {
|
|
160
|
+
const result = {};
|
|
161
|
+
for (const key of Reflect.ownKeys(headers)) {
|
|
162
|
+
if (typeof key === "symbol")
|
|
163
|
+
continue;
|
|
164
|
+
if (key.startsWith(":"))
|
|
165
|
+
continue;
|
|
166
|
+
const value = headers[key];
|
|
167
|
+
if (typeof value === "string") {
|
|
168
|
+
result[key] = value;
|
|
169
|
+
} else if (Array.isArray(value)) {
|
|
170
|
+
result[key] = value.join(", ");
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
159
175
|
|
|
160
176
|
exports.RezoHeaders = RezoHeaders;
|
|
177
|
+
exports.sanitizeHttp2Headers = sanitizeHttp2Headers;
|
|
161
178
|
exports.default = RezoHeaders;
|
|
162
179
|
module.exports = Object.assign(RezoHeaders, exports);
|
package/dist/utils/headers.js
CHANGED
|
@@ -156,6 +156,22 @@ class RezoHeaders extends Headers {
|
|
|
156
156
|
return "RezoHeaders";
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
+
function sanitizeHttp2Headers(headers) {
|
|
160
|
+
const result = {};
|
|
161
|
+
for (const key of Reflect.ownKeys(headers)) {
|
|
162
|
+
if (typeof key === "symbol")
|
|
163
|
+
continue;
|
|
164
|
+
if (key.startsWith(":"))
|
|
165
|
+
continue;
|
|
166
|
+
const value = headers[key];
|
|
167
|
+
if (typeof value === "string") {
|
|
168
|
+
result[key] = value;
|
|
169
|
+
} else if (Array.isArray(value)) {
|
|
170
|
+
result[key] = value.join(", ");
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
159
175
|
|
|
160
|
-
export { RezoHeaders };
|
|
176
|
+
export { RezoHeaders, sanitizeHttp2Headers };
|
|
161
177
|
export default RezoHeaders;
|
|
@@ -170,7 +170,11 @@ function setSignal() {
|
|
|
170
170
|
clearTimeout(this.timeoutClearInstanse);
|
|
171
171
|
if (this.timeout && typeof this.timeout === "number" && this.timeout > 100) {
|
|
172
172
|
const controller = new AbortController;
|
|
173
|
-
|
|
173
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
174
|
+
if (typeof timer === "object" && "unref" in timer) {
|
|
175
|
+
timer.unref();
|
|
176
|
+
}
|
|
177
|
+
this.timeoutClearInstanse = timer;
|
|
174
178
|
this.signal = controller.signal;
|
|
175
179
|
}
|
|
176
180
|
}
|
|
@@ -192,7 +196,8 @@ async function getDefaultConfig(config = {}, proxyManager) {
|
|
|
192
196
|
hooks: config.hooks,
|
|
193
197
|
cookieFile: config.cookieFile,
|
|
194
198
|
encoding: config.encoding,
|
|
195
|
-
proxyManager: proxyManager || null
|
|
199
|
+
proxyManager: proxyManager || null,
|
|
200
|
+
decompress: config.decompress
|
|
196
201
|
};
|
|
197
202
|
}
|
|
198
203
|
async function getFS() {
|
|
@@ -285,6 +290,9 @@ function prepareHTTPOptions(options, jar, addedOptions, config) {
|
|
|
285
290
|
}
|
|
286
291
|
}
|
|
287
292
|
}
|
|
293
|
+
if (cookiesString) {
|
|
294
|
+
fetchOptions.headers.set("Cookie", cookiesString);
|
|
295
|
+
}
|
|
288
296
|
if (options.body) {
|
|
289
297
|
fetchOptions.body = options.body;
|
|
290
298
|
}
|
|
@@ -301,7 +309,23 @@ function prepareHTTPOptions(options, jar, addedOptions, config) {
|
|
|
301
309
|
const _body = options.formData || options.multipart;
|
|
302
310
|
if (_body) {
|
|
303
311
|
Object.entries(_body).forEach(([key, value]) => {
|
|
304
|
-
|
|
312
|
+
if (value === null || value === undefined) {
|
|
313
|
+
body.append(key, "");
|
|
314
|
+
} else if (typeof value === "string" || Buffer.isBuffer(value)) {
|
|
315
|
+
body.append(key, value);
|
|
316
|
+
} else if (typeof value === "object" && typeof value.pipe === "function") {
|
|
317
|
+
body.append(key, value);
|
|
318
|
+
} else if (typeof value === "object" && value.value !== undefined) {
|
|
319
|
+
const val = value.value;
|
|
320
|
+
const opts = value.options || {};
|
|
321
|
+
if (typeof val === "string" || Buffer.isBuffer(val)) {
|
|
322
|
+
body.append(key, val, opts);
|
|
323
|
+
} else {
|
|
324
|
+
body.append(key, String(val), opts);
|
|
325
|
+
}
|
|
326
|
+
} else {
|
|
327
|
+
body.append(key, String(value));
|
|
328
|
+
}
|
|
305
329
|
});
|
|
306
330
|
}
|
|
307
331
|
contentType = body.getContentType();
|
|
@@ -337,7 +361,23 @@ function prepareHTTPOptions(options, jar, addedOptions, config) {
|
|
|
337
361
|
if (fetchOptions.body && typeof fetchOptions.body === "object") {
|
|
338
362
|
const formData = new RezoFormData;
|
|
339
363
|
Object.entries(fetchOptions.body).forEach(([key, value]) => {
|
|
340
|
-
|
|
364
|
+
if (value === null || value === undefined) {
|
|
365
|
+
formData.append(key, "");
|
|
366
|
+
} else if (typeof value === "string" || Buffer.isBuffer(value)) {
|
|
367
|
+
formData.append(key, value);
|
|
368
|
+
} else if (typeof value === "object" && typeof value.pipe === "function") {
|
|
369
|
+
formData.append(key, value);
|
|
370
|
+
} else if (typeof value === "object" && value.value !== undefined) {
|
|
371
|
+
const val = value.value;
|
|
372
|
+
const opts = value.options || {};
|
|
373
|
+
if (typeof val === "string" || Buffer.isBuffer(val)) {
|
|
374
|
+
formData.append(key, val, opts);
|
|
375
|
+
} else {
|
|
376
|
+
formData.append(key, String(val), opts);
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
formData.append(key, String(value));
|
|
380
|
+
}
|
|
341
381
|
});
|
|
342
382
|
fetchOptions.body = formData;
|
|
343
383
|
}
|
|
@@ -537,10 +577,12 @@ As a workaround, process.env.NODE_TLS_REJECT_UNAUTHORIZED is being set to '0'.
|
|
|
537
577
|
redirectHistory: [],
|
|
538
578
|
network: {},
|
|
539
579
|
timing: {},
|
|
580
|
+
transfer: {},
|
|
540
581
|
responseType: requestOptions.responseType,
|
|
541
582
|
proxy: normalizedProxy,
|
|
542
583
|
enableRedirectCycleDetection,
|
|
543
|
-
rejectUnauthorized: typeof rejectUnauthorized === "boolean" ? rejectUnauthorized : true
|
|
584
|
+
rejectUnauthorized: typeof rejectUnauthorized === "boolean" ? rejectUnauthorized : true,
|
|
585
|
+
decompress: typeof requestOptions.decompress === "boolean" ? requestOptions.decompress : typeof defaultOptions.decompress === "boolean" ? defaultOptions.decompress : true
|
|
544
586
|
};
|
|
545
587
|
config.setSignal = setSignal.bind(config);
|
|
546
588
|
if (requestOptions.encoding || defaultOptions.encoding) {
|
|
@@ -170,7 +170,11 @@ function setSignal() {
|
|
|
170
170
|
clearTimeout(this.timeoutClearInstanse);
|
|
171
171
|
if (this.timeout && typeof this.timeout === "number" && this.timeout > 100) {
|
|
172
172
|
const controller = new AbortController;
|
|
173
|
-
|
|
173
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
174
|
+
if (typeof timer === "object" && "unref" in timer) {
|
|
175
|
+
timer.unref();
|
|
176
|
+
}
|
|
177
|
+
this.timeoutClearInstanse = timer;
|
|
174
178
|
this.signal = controller.signal;
|
|
175
179
|
}
|
|
176
180
|
}
|
|
@@ -192,7 +196,8 @@ export async function getDefaultConfig(config = {}, proxyManager) {
|
|
|
192
196
|
hooks: config.hooks,
|
|
193
197
|
cookieFile: config.cookieFile,
|
|
194
198
|
encoding: config.encoding,
|
|
195
|
-
proxyManager: proxyManager || null
|
|
199
|
+
proxyManager: proxyManager || null,
|
|
200
|
+
decompress: config.decompress
|
|
196
201
|
};
|
|
197
202
|
}
|
|
198
203
|
export async function getFS() {
|
|
@@ -285,6 +290,9 @@ export function prepareHTTPOptions(options, jar, addedOptions, config) {
|
|
|
285
290
|
}
|
|
286
291
|
}
|
|
287
292
|
}
|
|
293
|
+
if (cookiesString) {
|
|
294
|
+
fetchOptions.headers.set("Cookie", cookiesString);
|
|
295
|
+
}
|
|
288
296
|
if (options.body) {
|
|
289
297
|
fetchOptions.body = options.body;
|
|
290
298
|
}
|
|
@@ -301,7 +309,23 @@ export function prepareHTTPOptions(options, jar, addedOptions, config) {
|
|
|
301
309
|
const _body = options.formData || options.multipart;
|
|
302
310
|
if (_body) {
|
|
303
311
|
Object.entries(_body).forEach(([key, value]) => {
|
|
304
|
-
|
|
312
|
+
if (value === null || value === undefined) {
|
|
313
|
+
body.append(key, "");
|
|
314
|
+
} else if (typeof value === "string" || Buffer.isBuffer(value)) {
|
|
315
|
+
body.append(key, value);
|
|
316
|
+
} else if (typeof value === "object" && typeof value.pipe === "function") {
|
|
317
|
+
body.append(key, value);
|
|
318
|
+
} else if (typeof value === "object" && value.value !== undefined) {
|
|
319
|
+
const val = value.value;
|
|
320
|
+
const opts = value.options || {};
|
|
321
|
+
if (typeof val === "string" || Buffer.isBuffer(val)) {
|
|
322
|
+
body.append(key, val, opts);
|
|
323
|
+
} else {
|
|
324
|
+
body.append(key, String(val), opts);
|
|
325
|
+
}
|
|
326
|
+
} else {
|
|
327
|
+
body.append(key, String(value));
|
|
328
|
+
}
|
|
305
329
|
});
|
|
306
330
|
}
|
|
307
331
|
contentType = body.getContentType();
|
|
@@ -337,7 +361,23 @@ export function prepareHTTPOptions(options, jar, addedOptions, config) {
|
|
|
337
361
|
if (fetchOptions.body && typeof fetchOptions.body === "object") {
|
|
338
362
|
const formData = new RezoFormData;
|
|
339
363
|
Object.entries(fetchOptions.body).forEach(([key, value]) => {
|
|
340
|
-
|
|
364
|
+
if (value === null || value === undefined) {
|
|
365
|
+
formData.append(key, "");
|
|
366
|
+
} else if (typeof value === "string" || Buffer.isBuffer(value)) {
|
|
367
|
+
formData.append(key, value);
|
|
368
|
+
} else if (typeof value === "object" && typeof value.pipe === "function") {
|
|
369
|
+
formData.append(key, value);
|
|
370
|
+
} else if (typeof value === "object" && value.value !== undefined) {
|
|
371
|
+
const val = value.value;
|
|
372
|
+
const opts = value.options || {};
|
|
373
|
+
if (typeof val === "string" || Buffer.isBuffer(val)) {
|
|
374
|
+
formData.append(key, val, opts);
|
|
375
|
+
} else {
|
|
376
|
+
formData.append(key, String(val), opts);
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
formData.append(key, String(value));
|
|
380
|
+
}
|
|
341
381
|
});
|
|
342
382
|
fetchOptions.body = formData;
|
|
343
383
|
}
|
|
@@ -537,10 +577,12 @@ As a workaround, process.env.NODE_TLS_REJECT_UNAUTHORIZED is being set to '0'.
|
|
|
537
577
|
redirectHistory: [],
|
|
538
578
|
network: {},
|
|
539
579
|
timing: {},
|
|
580
|
+
transfer: {},
|
|
540
581
|
responseType: requestOptions.responseType,
|
|
541
582
|
proxy: normalizedProxy,
|
|
542
583
|
enableRedirectCycleDetection,
|
|
543
|
-
rejectUnauthorized: typeof rejectUnauthorized === "boolean" ? rejectUnauthorized : true
|
|
584
|
+
rejectUnauthorized: typeof rejectUnauthorized === "boolean" ? rejectUnauthorized : true,
|
|
585
|
+
decompress: typeof requestOptions.decompress === "boolean" ? requestOptions.decompress : typeof defaultOptions.decompress === "boolean" ? defaultOptions.decompress : true
|
|
544
586
|
};
|
|
545
587
|
config.setSignal = setSignal.bind(config);
|
|
546
588
|
if (requestOptions.encoding || defaultOptions.encoding) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rezo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Lightning-fast, enterprise-grade HTTP client for modern JavaScript. Full HTTP/2 support, intelligent cookie management, multiple adapters (HTTP, Fetch, cURL, XHR), streaming, proxy support (HTTP/HTTPS/SOCKS), and cross-environment compatibility.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|