rezo 1.0.11 → 1.0.12

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.
@@ -1,8 +1,8 @@
1
- const _mod_9p4qhc = require('./queue.cjs');
2
- exports.RezoQueue = _mod_9p4qhc.RezoQueue;;
3
- const _mod_iowt5d = require('./http-queue.cjs');
4
- exports.HttpQueue = _mod_iowt5d.HttpQueue;
5
- exports.extractDomain = _mod_iowt5d.extractDomain;;
6
- const _mod_ihr43x = require('./types.cjs');
7
- exports.Priority = _mod_ihr43x.Priority;
8
- exports.HttpMethodPriority = _mod_ihr43x.HttpMethodPriority;;
1
+ const _mod_ipfe1q = require('./queue.cjs');
2
+ exports.RezoQueue = _mod_ipfe1q.RezoQueue;;
3
+ const _mod_sc99zf = require('./http-queue.cjs');
4
+ exports.HttpQueue = _mod_sc99zf.HttpQueue;
5
+ exports.extractDomain = _mod_sc99zf.extractDomain;;
6
+ const _mod_4akyyt = require('./types.cjs');
7
+ exports.Priority = _mod_4akyyt.Priority;
8
+ exports.HttpMethodPriority = _mod_4akyyt.HttpMethodPriority;;
@@ -297,11 +297,36 @@ function buildResponse(params) {
297
297
  const rezoHeaders = new RezoHeaders(headers);
298
298
  rezoHeaders.delete("set-cookie");
299
299
  let cookieData;
300
+ const mergedCookiesArray = [];
301
+ const cookieKeyDomainMap = new Map;
302
+ if (config.requestCookies && config.requestCookies.length > 0) {
303
+ for (const cookie of config.requestCookies) {
304
+ const key = `${cookie.key}|${cookie.domain || ""}`;
305
+ mergedCookiesArray.push(cookie);
306
+ cookieKeyDomainMap.set(key, mergedCookiesArray.length - 1);
307
+ }
308
+ }
309
+ let responseCookiesArray = [];
300
310
  if (config.responseCookies && config.responseCookies.array && config.responseCookies.array.length > 0) {
301
- cookieData = config.responseCookies;
311
+ responseCookiesArray = config.responseCookies.array;
302
312
  } else if (cookies.length > 0) {
303
- const cookieJar = new RezoCookieJar;
304
- cookieData = cookieJar.setCookiesSync(cookies, url);
313
+ const tempJar = new RezoCookieJar;
314
+ const parsed = tempJar.setCookiesSync(cookies, url);
315
+ responseCookiesArray = parsed.array;
316
+ }
317
+ for (const cookie of responseCookiesArray) {
318
+ const key = `${cookie.key}|${cookie.domain || ""}`;
319
+ const existingIndex = cookieKeyDomainMap.get(key);
320
+ if (existingIndex !== undefined) {
321
+ mergedCookiesArray[existingIndex] = cookie;
322
+ } else {
323
+ mergedCookiesArray.push(cookie);
324
+ cookieKeyDomainMap.set(key, mergedCookiesArray.length - 1);
325
+ }
326
+ }
327
+ if (mergedCookiesArray.length > 0) {
328
+ const mergedJar = new RezoCookieJar(mergedCookiesArray, url);
329
+ cookieData = mergedJar.cookies();
305
330
  } else {
306
331
  cookieData = {
307
332
  array: [],
@@ -297,11 +297,36 @@ export function buildResponse(params) {
297
297
  const rezoHeaders = new RezoHeaders(headers);
298
298
  rezoHeaders.delete("set-cookie");
299
299
  let cookieData;
300
+ const mergedCookiesArray = [];
301
+ const cookieKeyDomainMap = new Map;
302
+ if (config.requestCookies && config.requestCookies.length > 0) {
303
+ for (const cookie of config.requestCookies) {
304
+ const key = `${cookie.key}|${cookie.domain || ""}`;
305
+ mergedCookiesArray.push(cookie);
306
+ cookieKeyDomainMap.set(key, mergedCookiesArray.length - 1);
307
+ }
308
+ }
309
+ let responseCookiesArray = [];
300
310
  if (config.responseCookies && config.responseCookies.array && config.responseCookies.array.length > 0) {
301
- cookieData = config.responseCookies;
311
+ responseCookiesArray = config.responseCookies.array;
302
312
  } else if (cookies.length > 0) {
303
- const cookieJar = new RezoCookieJar;
304
- cookieData = cookieJar.setCookiesSync(cookies, url);
313
+ const tempJar = new RezoCookieJar;
314
+ const parsed = tempJar.setCookiesSync(cookies, url);
315
+ responseCookiesArray = parsed.array;
316
+ }
317
+ for (const cookie of responseCookiesArray) {
318
+ const key = `${cookie.key}|${cookie.domain || ""}`;
319
+ const existingIndex = cookieKeyDomainMap.get(key);
320
+ if (existingIndex !== undefined) {
321
+ mergedCookiesArray[existingIndex] = cookie;
322
+ } else {
323
+ mergedCookiesArray.push(cookie);
324
+ cookieKeyDomainMap.set(key, mergedCookiesArray.length - 1);
325
+ }
326
+ }
327
+ if (mergedCookiesArray.length > 0) {
328
+ const mergedJar = new RezoCookieJar(mergedCookiesArray, url);
329
+ cookieData = mergedJar.cookies();
305
330
  } else {
306
331
  cookieData = {
307
332
  array: [],
@@ -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
- this.timeoutClearInstanse = setTimeout(() => controller.abort(), this.timeout);
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
  }
@@ -285,6 +289,9 @@ function prepareHTTPOptions(options, jar, addedOptions, config) {
285
289
  }
286
290
  }
287
291
  }
292
+ if (cookiesString) {
293
+ fetchOptions.headers.set("Cookie", cookiesString);
294
+ }
288
295
  if (options.body) {
289
296
  fetchOptions.body = options.body;
290
297
  }
@@ -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
- this.timeoutClearInstanse = setTimeout(() => controller.abort(), this.timeout);
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
  }
@@ -285,6 +289,9 @@ export function prepareHTTPOptions(options, jar, addedOptions, config) {
285
289
  }
286
290
  }
287
291
  }
292
+ if (cookiesString) {
293
+ fetchOptions.headers.set("Cookie", cookiesString);
294
+ }
288
295
  if (options.body) {
289
296
  fetchOptions.body = options.body;
290
297
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rezo",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
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",