@mswjs/interceptors 0.37.4 → 0.37.6

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.
Files changed (66) hide show
  1. package/lib/browser/{chunk-F4BN745U.mjs → chunk-5UK33FSU.mjs} +11 -1
  2. package/lib/browser/chunk-5UK33FSU.mjs.map +1 -0
  3. package/lib/browser/{chunk-CANMNIJA.js → chunk-BC2BLJQN.js} +11 -1
  4. package/lib/browser/chunk-BC2BLJQN.js.map +1 -0
  5. package/lib/browser/{chunk-7SL7RZNU.mjs → chunk-DODHRDV6.mjs} +2 -2
  6. package/lib/browser/{chunk-74GCTBGJ.js → chunk-QVOTKFTB.js} +8 -8
  7. package/lib/browser/{chunk-HER3NHBG.mjs → chunk-XTX2SIN6.mjs} +2 -2
  8. package/lib/browser/{chunk-UJNACJXF.js → chunk-ZIT2QX7D.js} +7 -7
  9. package/lib/browser/index.d.ts +4 -0
  10. package/lib/browser/index.js +2 -2
  11. package/lib/browser/index.mjs +1 -1
  12. package/lib/browser/interceptors/XMLHttpRequest/index.js +3 -3
  13. package/lib/browser/interceptors/XMLHttpRequest/index.mjs +2 -2
  14. package/lib/browser/interceptors/fetch/index.js +3 -3
  15. package/lib/browser/interceptors/fetch/index.mjs +2 -2
  16. package/lib/browser/presets/browser.js +5 -5
  17. package/lib/browser/presets/browser.mjs +3 -3
  18. package/lib/node/RemoteHttpInterceptor.js +9 -9
  19. package/lib/node/RemoteHttpInterceptor.mjs +4 -4
  20. package/lib/node/{chunk-ZFSEKZ4Y.js → chunk-3HCE66HZ.js} +27 -25
  21. package/lib/node/chunk-3HCE66HZ.js.map +1 -0
  22. package/lib/node/{chunk-7XUH4W74.mjs → chunk-CTGTMEFD.mjs} +2 -2
  23. package/lib/node/{chunk-ZHMQHI2Z.mjs → chunk-FWJSC2QD.mjs} +20 -18
  24. package/lib/node/chunk-FWJSC2QD.mjs.map +1 -0
  25. package/lib/node/{chunk-ELLF26MW.mjs → chunk-I7HQIBT7.mjs} +11 -1
  26. package/lib/node/{chunk-ELLF26MW.mjs.map → chunk-I7HQIBT7.mjs.map} +1 -1
  27. package/lib/node/{chunk-XP2VS4IL.js → chunk-LCA4FKWY.js} +7 -7
  28. package/lib/node/{chunk-C2QGGUHP.js → chunk-LEA3MUU3.js} +7 -7
  29. package/lib/node/{chunk-WISH7OVU.mjs → chunk-OMWE7UVM.mjs} +2 -2
  30. package/lib/node/{chunk-3CPL565R.mjs → chunk-PJA4E426.mjs} +2 -2
  31. package/lib/node/{chunk-WGMDPBIX.js → chunk-WZTE4PCO.js} +11 -1
  32. package/lib/node/chunk-WZTE4PCO.js.map +1 -0
  33. package/lib/node/{chunk-YMPTXPHD.js → chunk-YBN5MFAP.js} +3 -3
  34. package/lib/node/index.d.ts +4 -0
  35. package/lib/node/index.js +3 -3
  36. package/lib/node/index.mjs +2 -2
  37. package/lib/node/interceptors/ClientRequest/index.js +3 -3
  38. package/lib/node/interceptors/ClientRequest/index.mjs +2 -2
  39. package/lib/node/interceptors/XMLHttpRequest/index.js +3 -3
  40. package/lib/node/interceptors/XMLHttpRequest/index.mjs +2 -2
  41. package/lib/node/interceptors/fetch/index.js +3 -3
  42. package/lib/node/interceptors/fetch/index.mjs +2 -2
  43. package/lib/node/presets/node.js +7 -7
  44. package/lib/node/presets/node.mjs +4 -4
  45. package/package.json +1 -1
  46. package/src/interceptors/ClientRequest/MockHttpSocket.ts +2 -3
  47. package/src/interceptors/ClientRequest/agents.ts +25 -8
  48. package/src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.test.ts +44 -0
  49. package/src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.ts +4 -1
  50. package/src/utils/fetchUtils.ts +11 -0
  51. package/lib/browser/chunk-CANMNIJA.js.map +0 -1
  52. package/lib/browser/chunk-F4BN745U.mjs.map +0 -1
  53. package/lib/node/chunk-WGMDPBIX.js.map +0 -1
  54. package/lib/node/chunk-ZFSEKZ4Y.js.map +0 -1
  55. package/lib/node/chunk-ZHMQHI2Z.mjs.map +0 -1
  56. package/src/interceptors/Socket/utils/parseRawHeaders.ts +0 -10
  57. /package/lib/browser/{chunk-7SL7RZNU.mjs.map → chunk-DODHRDV6.mjs.map} +0 -0
  58. /package/lib/browser/{chunk-74GCTBGJ.js.map → chunk-QVOTKFTB.js.map} +0 -0
  59. /package/lib/browser/{chunk-HER3NHBG.mjs.map → chunk-XTX2SIN6.mjs.map} +0 -0
  60. /package/lib/browser/{chunk-UJNACJXF.js.map → chunk-ZIT2QX7D.js.map} +0 -0
  61. /package/lib/node/{chunk-7XUH4W74.mjs.map → chunk-CTGTMEFD.mjs.map} +0 -0
  62. /package/lib/node/{chunk-XP2VS4IL.js.map → chunk-LCA4FKWY.js.map} +0 -0
  63. /package/lib/node/{chunk-C2QGGUHP.js.map → chunk-LEA3MUU3.js.map} +0 -0
  64. /package/lib/node/{chunk-WISH7OVU.mjs.map → chunk-OMWE7UVM.mjs.map} +0 -0
  65. /package/lib/node/{chunk-3CPL565R.mjs.map → chunk-PJA4E426.mjs.map} +0 -0
  66. /package/lib/node/{chunk-YMPTXPHD.js.map → chunk-YBN5MFAP.js.map} +0 -0
@@ -30,6 +30,16 @@ var _FetchResponse = class extends Response {
30
30
  writable: false
31
31
  });
32
32
  }
33
+ /**
34
+ * Parses the given raw HTTP headers into a Fetch API `Headers` instance.
35
+ */
36
+ static parseRawHeaders(rawHeaders) {
37
+ const headers = new Headers();
38
+ for (let line = 0; line < rawHeaders.length; line += 2) {
39
+ headers.append(rawHeaders[line], rawHeaders[line + 1]);
40
+ }
41
+ return headers;
42
+ }
33
43
  constructor(body, init = {}) {
34
44
  var _a;
35
45
  const status = (_a = init.status) != null ? _a : 200;
@@ -70,4 +80,4 @@ export {
70
80
  IS_PATCHED_MODULE,
71
81
  FetchResponse
72
82
  };
73
- //# sourceMappingURL=chunk-F4BN745U.mjs.map
83
+ //# sourceMappingURL=chunk-5UK33FSU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/glossary.ts","../../src/utils/fetchUtils.ts"],"sourcesContent":["import type { RequestController } from './RequestController'\n\nexport const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')\n\n/**\n * @note Export `RequestController` as a type only.\n * It's never meant to be created in the userland.\n */\nexport type { RequestController }\n\nexport type RequestCredentials = 'omit' | 'include' | 'same-origin'\n\nexport type HttpRequestEventMap = {\n request: [\n args: {\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n response: [\n args: {\n response: Response\n isMockedResponse: boolean\n request: Request\n requestId: string\n }\n ]\n unhandledException: [\n args: {\n error: unknown\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n}\n","export interface FetchResponseInit extends ResponseInit {\n url?: string\n}\n\nexport class FetchResponse extends Response {\n /**\n * Response status codes for responses that cannot have body.\n * @see https://fetch.spec.whatwg.org/#statuses\n */\n static readonly STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304]\n\n static readonly STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308]\n\n static isConfigurableStatusCode(status: number): boolean {\n return status >= 200 && status <= 599\n }\n\n static isRedirectResponse(status: number): boolean {\n return FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status)\n }\n\n /**\n * Returns a boolean indicating whether the given response status\n * code represents a response that can have a body.\n */\n static isResponseWithBody(status: number): boolean {\n return !FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status)\n }\n\n static setUrl(url: string | undefined, response: Response): void {\n if (!url) {\n return\n }\n\n if (response.url != '') {\n return\n }\n\n Object.defineProperty(response, 'url', {\n value: url,\n enumerable: true,\n configurable: true,\n writable: false,\n })\n }\n\n /**\n * Parses the given raw HTTP headers into a Fetch API `Headers` instance.\n */\n static parseRawHeaders(rawHeaders: Array<string>): Headers {\n const headers = new Headers()\n for (let line = 0; line < rawHeaders.length; line += 2) {\n headers.append(rawHeaders[line], rawHeaders[line + 1])\n }\n return headers\n }\n\n constructor(body?: BodyInit | null, init: FetchResponseInit = {}) {\n const status = init.status ?? 200\n const safeStatus = FetchResponse.isConfigurableStatusCode(status)\n ? status\n : 200\n const finalBody = FetchResponse.isResponseWithBody(status) ? body : null\n\n super(finalBody, {\n ...init,\n status: safeStatus,\n })\n\n if (status !== safeStatus) {\n /**\n * @note Undici keeps an internal \"Symbol(state)\" that holds\n * the actual value of response status. Update that in Node.js.\n */\n const stateSymbol = Object.getOwnPropertySymbols(this).find(\n (symbol) => symbol.description === 'state'\n )\n if (stateSymbol) {\n const state = Reflect.get(this, stateSymbol) as object\n Reflect.set(state, 'status', status)\n } else {\n Object.defineProperty(this, 'status', {\n value: status,\n enumerable: true,\n configurable: true,\n writable: false,\n })\n }\n }\n\n FetchResponse.setUrl(init.url, this)\n }\n}\n"],"mappings":";AAEO,IAAM,oBAAmC,OAAO,iBAAiB;;;ACEjE,IAAM,iBAAN,cAA4B,SAAS;AAAA,EAS1C,OAAO,yBAAyB,QAAyB;AACvD,WAAO,UAAU,OAAO,UAAU;AAAA,EACpC;AAAA,EAEA,OAAO,mBAAmB,QAAyB;AACjD,WAAO,eAAc,2BAA2B,SAAS,MAAM;AAAA,EACjE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,mBAAmB,QAAyB;AACjD,WAAO,CAAC,eAAc,0BAA0B,SAAS,MAAM;AAAA,EACjE;AAAA,EAEA,OAAO,OAAO,KAAyB,UAA0B;AAC/D,QAAI,CAAC,KAAK;AACR;AAAA,IACF;AAEA,QAAI,SAAS,OAAO,IAAI;AACtB;AAAA,IACF;AAEA,WAAO,eAAe,UAAU,OAAO;AAAA,MACrC,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,gBAAgB,YAAoC;AACzD,UAAM,UAAU,IAAI,QAAQ;AAC5B,aAAS,OAAO,GAAG,OAAO,WAAW,QAAQ,QAAQ,GAAG;AACtD,cAAQ,OAAO,WAAW,IAAI,GAAG,WAAW,OAAO,CAAC,CAAC;AAAA,IACvD;AACA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAAwB,OAA0B,CAAC,GAAG;AAzDpE;AA0DI,UAAM,UAAS,UAAK,WAAL,YAAe;AAC9B,UAAM,aAAa,eAAc,yBAAyB,MAAM,IAC5D,SACA;AACJ,UAAM,YAAY,eAAc,mBAAmB,MAAM,IAAI,OAAO;AAEpE,UAAM,WAAW;AAAA,MACf,GAAG;AAAA,MACH,QAAQ;AAAA,IACV,CAAC;AAED,QAAI,WAAW,YAAY;AAKzB,YAAM,cAAc,OAAO,sBAAsB,IAAI,EAAE;AAAA,QACrD,CAAC,WAAW,OAAO,gBAAgB;AAAA,MACrC;AACA,UAAI,aAAa;AACf,cAAM,QAAQ,QAAQ,IAAI,MAAM,WAAW;AAC3C,gBAAQ,IAAI,OAAO,UAAU,MAAM;AAAA,MACrC,OAAO;AACL,eAAO,eAAe,MAAM,UAAU;AAAA,UACpC,OAAO;AAAA,UACP,YAAY;AAAA,UACZ,cAAc;AAAA,UACd,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA,IACF;AAEA,mBAAc,OAAO,KAAK,KAAK,IAAI;AAAA,EACrC;AACF;AAxFO,IAAM,gBAAN;AAAA;AAAA;AAAA;AAAA;AAAM,cAKK,4BAA4B,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG;AALzD,cAOK,6BAA6B,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG;","names":[]}
@@ -30,6 +30,16 @@ var _FetchResponse = class extends Response {
30
30
  writable: false
31
31
  });
32
32
  }
33
+ /**
34
+ * Parses the given raw HTTP headers into a Fetch API `Headers` instance.
35
+ */
36
+ static parseRawHeaders(rawHeaders) {
37
+ const headers = new Headers();
38
+ for (let line = 0; line < rawHeaders.length; line += 2) {
39
+ headers.append(rawHeaders[line], rawHeaders[line + 1]);
40
+ }
41
+ return headers;
42
+ }
33
43
  constructor(body, init = {}) {
34
44
  var _a;
35
45
  const status = (_a = init.status) != null ? _a : 200;
@@ -70,4 +80,4 @@ FetchResponse.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308];
70
80
 
71
81
 
72
82
  exports.IS_PATCHED_MODULE = IS_PATCHED_MODULE; exports.FetchResponse = FetchResponse;
73
- //# sourceMappingURL=chunk-CANMNIJA.js.map
83
+ //# sourceMappingURL=chunk-BC2BLJQN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/glossary.ts","../../src/utils/fetchUtils.ts"],"names":[],"mappings":";AAEO,IAAM,oBAAmC,OAAO,iBAAiB;;;ACEjE,IAAM,iBAAN,cAA4B,SAAS;AAAA,EAS1C,OAAO,yBAAyB,QAAyB;AACvD,WAAO,UAAU,OAAO,UAAU;AAAA,EACpC;AAAA,EAEA,OAAO,mBAAmB,QAAyB;AACjD,WAAO,eAAc,2BAA2B,SAAS,MAAM;AAAA,EACjE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,mBAAmB,QAAyB;AACjD,WAAO,CAAC,eAAc,0BAA0B,SAAS,MAAM;AAAA,EACjE;AAAA,EAEA,OAAO,OAAO,KAAyB,UAA0B;AAC/D,QAAI,CAAC,KAAK;AACR;AAAA,IACF;AAEA,QAAI,SAAS,OAAO,IAAI;AACtB;AAAA,IACF;AAEA,WAAO,eAAe,UAAU,OAAO;AAAA,MACrC,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,gBAAgB,YAAoC;AACzD,UAAM,UAAU,IAAI,QAAQ;AAC5B,aAAS,OAAO,GAAG,OAAO,WAAW,QAAQ,QAAQ,GAAG;AACtD,cAAQ,OAAO,WAAW,IAAI,GAAG,WAAW,OAAO,CAAC,CAAC;AAAA,IACvD;AACA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAAwB,OAA0B,CAAC,GAAG;AAzDpE;AA0DI,UAAM,UAAS,UAAK,WAAL,YAAe;AAC9B,UAAM,aAAa,eAAc,yBAAyB,MAAM,IAC5D,SACA;AACJ,UAAM,YAAY,eAAc,mBAAmB,MAAM,IAAI,OAAO;AAEpE,UAAM,WAAW;AAAA,MACf,GAAG;AAAA,MACH,QAAQ;AAAA,IACV,CAAC;AAED,QAAI,WAAW,YAAY;AAKzB,YAAM,cAAc,OAAO,sBAAsB,IAAI,EAAE;AAAA,QACrD,CAAC,WAAW,OAAO,gBAAgB;AAAA,MACrC;AACA,UAAI,aAAa;AACf,cAAM,QAAQ,QAAQ,IAAI,MAAM,WAAW;AAC3C,gBAAQ,IAAI,OAAO,UAAU,MAAM;AAAA,MACrC,OAAO;AACL,eAAO,eAAe,MAAM,UAAU;AAAA,UACpC,OAAO;AAAA,UACP,YAAY;AAAA,UACZ,cAAc;AAAA,UACd,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA,IACF;AAEA,mBAAc,OAAO,KAAK,KAAK,IAAI;AAAA,EACrC;AACF;AAxFO,IAAM,gBAAN;AAAA;AAAA;AAAA;AAAA;AAAM,cAKK,4BAA4B,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG;AALzD,cAOK,6BAA6B,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG","sourcesContent":["import type { RequestController } from './RequestController'\n\nexport const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')\n\n/**\n * @note Export `RequestController` as a type only.\n * It's never meant to be created in the userland.\n */\nexport type { RequestController }\n\nexport type RequestCredentials = 'omit' | 'include' | 'same-origin'\n\nexport type HttpRequestEventMap = {\n request: [\n args: {\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n response: [\n args: {\n response: Response\n isMockedResponse: boolean\n request: Request\n requestId: string\n }\n ]\n unhandledException: [\n args: {\n error: unknown\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n}\n","export interface FetchResponseInit extends ResponseInit {\n url?: string\n}\n\nexport class FetchResponse extends Response {\n /**\n * Response status codes for responses that cannot have body.\n * @see https://fetch.spec.whatwg.org/#statuses\n */\n static readonly STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304]\n\n static readonly STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308]\n\n static isConfigurableStatusCode(status: number): boolean {\n return status >= 200 && status <= 599\n }\n\n static isRedirectResponse(status: number): boolean {\n return FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status)\n }\n\n /**\n * Returns a boolean indicating whether the given response status\n * code represents a response that can have a body.\n */\n static isResponseWithBody(status: number): boolean {\n return !FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status)\n }\n\n static setUrl(url: string | undefined, response: Response): void {\n if (!url) {\n return\n }\n\n if (response.url != '') {\n return\n }\n\n Object.defineProperty(response, 'url', {\n value: url,\n enumerable: true,\n configurable: true,\n writable: false,\n })\n }\n\n /**\n * Parses the given raw HTTP headers into a Fetch API `Headers` instance.\n */\n static parseRawHeaders(rawHeaders: Array<string>): Headers {\n const headers = new Headers()\n for (let line = 0; line < rawHeaders.length; line += 2) {\n headers.append(rawHeaders[line], rawHeaders[line + 1])\n }\n return headers\n }\n\n constructor(body?: BodyInit | null, init: FetchResponseInit = {}) {\n const status = init.status ?? 200\n const safeStatus = FetchResponse.isConfigurableStatusCode(status)\n ? status\n : 200\n const finalBody = FetchResponse.isResponseWithBody(status) ? body : null\n\n super(finalBody, {\n ...init,\n status: safeStatus,\n })\n\n if (status !== safeStatus) {\n /**\n * @note Undici keeps an internal \"Symbol(state)\" that holds\n * the actual value of response status. Update that in Node.js.\n */\n const stateSymbol = Object.getOwnPropertySymbols(this).find(\n (symbol) => symbol.description === 'state'\n )\n if (stateSymbol) {\n const state = Reflect.get(this, stateSymbol) as object\n Reflect.set(state, 'status', status)\n } else {\n Object.defineProperty(this, 'status', {\n value: status,\n enumerable: true,\n configurable: true,\n writable: false,\n })\n }\n }\n\n FetchResponse.setUrl(init.url, this)\n }\n}\n"]}
@@ -10,7 +10,7 @@ import {
10
10
  import {
11
11
  FetchResponse,
12
12
  IS_PATCHED_MODULE
13
- } from "./chunk-F4BN745U.mjs";
13
+ } from "./chunk-5UK33FSU.mjs";
14
14
  import {
15
15
  hasConfigurableGlobal
16
16
  } from "./chunk-TX5GBTFY.mjs";
@@ -841,4 +841,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
841
841
  export {
842
842
  XMLHttpRequestInterceptor
843
843
  };
844
- //# sourceMappingURL=chunk-7SL7RZNU.mjs.map
844
+ //# sourceMappingURL=chunk-DODHRDV6.mjs.map
@@ -6,7 +6,7 @@ var _chunkFGSEOIC4js = require('./chunk-FGSEOIC4.js');
6
6
 
7
7
 
8
8
 
9
- var _chunkCANMNIJAjs = require('./chunk-CANMNIJA.js');
9
+ var _chunkBC2BLJQNjs = require('./chunk-BC2BLJQN.js');
10
10
 
11
11
 
12
12
  var _chunkPFGO5BSMjs = require('./chunk-PFGO5BSM.js');
@@ -180,7 +180,7 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
180
180
  async setup() {
181
181
  const pureFetch = globalThis.fetch;
182
182
  _outvariant.invariant.call(void 0,
183
- !pureFetch[_chunkCANMNIJAjs.IS_PATCHED_MODULE],
183
+ !pureFetch[_chunkBC2BLJQNjs.IS_PATCHED_MODULE],
184
184
  'Failed to patch the "fetch" module: already patched.'
185
185
  );
186
186
  globalThis.fetch = async (input, init) => {
@@ -205,9 +205,9 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
205
205
  rawResponse
206
206
  });
207
207
  const decompressedStream = decompressResponse(rawResponse);
208
- const response = decompressedStream === null ? rawResponse : new (0, _chunkCANMNIJAjs.FetchResponse)(decompressedStream, rawResponse);
209
- _chunkCANMNIJAjs.FetchResponse.setUrl(request.url, response);
210
- if (_chunkCANMNIJAjs.FetchResponse.isRedirectResponse(response.status)) {
208
+ const response = decompressedStream === null ? rawResponse : new (0, _chunkBC2BLJQNjs.FetchResponse)(decompressedStream, rawResponse);
209
+ _chunkBC2BLJQNjs.FetchResponse.setUrl(request.url, response);
210
+ if (_chunkBC2BLJQNjs.FetchResponse.isRedirectResponse(response.status)) {
211
211
  if (request.redirect === "error") {
212
212
  responsePromise.reject(createNetworkError("unexpected redirect"));
213
213
  return;
@@ -269,13 +269,13 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
269
269
  return response;
270
270
  });
271
271
  };
272
- Object.defineProperty(globalThis.fetch, _chunkCANMNIJAjs.IS_PATCHED_MODULE, {
272
+ Object.defineProperty(globalThis.fetch, _chunkBC2BLJQNjs.IS_PATCHED_MODULE, {
273
273
  enumerable: true,
274
274
  configurable: true,
275
275
  value: true
276
276
  });
277
277
  this.subscriptions.push(() => {
278
- Object.defineProperty(globalThis.fetch, _chunkCANMNIJAjs.IS_PATCHED_MODULE, {
278
+ Object.defineProperty(globalThis.fetch, _chunkBC2BLJQNjs.IS_PATCHED_MODULE, {
279
279
  value: void 0
280
280
  });
281
281
  globalThis.fetch = pureFetch;
@@ -292,4 +292,4 @@ FetchInterceptor.symbol = Symbol("fetch");
292
292
 
293
293
 
294
294
  exports.FetchInterceptor = FetchInterceptor;
295
- //# sourceMappingURL=chunk-74GCTBGJ.js.map
295
+ //# sourceMappingURL=chunk-QVOTKFTB.js.map
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  FetchResponse,
8
8
  IS_PATCHED_MODULE
9
- } from "./chunk-F4BN745U.mjs";
9
+ } from "./chunk-5UK33FSU.mjs";
10
10
  import {
11
11
  hasConfigurableGlobal
12
12
  } from "./chunk-TX5GBTFY.mjs";
@@ -292,4 +292,4 @@ FetchInterceptor.symbol = Symbol("fetch");
292
292
  export {
293
293
  FetchInterceptor
294
294
  };
295
- //# sourceMappingURL=chunk-HER3NHBG.mjs.map
295
+ //# sourceMappingURL=chunk-XTX2SIN6.mjs.map
@@ -10,7 +10,7 @@ var _chunkFGSEOIC4js = require('./chunk-FGSEOIC4.js');
10
10
 
11
11
 
12
12
 
13
- var _chunkCANMNIJAjs = require('./chunk-CANMNIJA.js');
13
+ var _chunkBC2BLJQNjs = require('./chunk-BC2BLJQN.js');
14
14
 
15
15
 
16
16
  var _chunkPFGO5BSMjs = require('./chunk-PFGO5BSM.js');
@@ -206,8 +206,8 @@ function parseJson(data) {
206
206
 
207
207
  // src/interceptors/XMLHttpRequest/utils/createResponse.ts
208
208
  function createResponse(request, body) {
209
- const responseBodyOrNull = _chunkCANMNIJAjs.FetchResponse.isResponseWithBody(request.status) ? body : null;
210
- return new (0, _chunkCANMNIJAjs.FetchResponse)(responseBodyOrNull, {
209
+ const responseBodyOrNull = _chunkBC2BLJQNjs.FetchResponse.isResponseWithBody(request.status) ? body : null;
210
+ return new (0, _chunkBC2BLJQNjs.FetchResponse)(responseBodyOrNull, {
211
211
  url: request.responseURL,
212
212
  status: request.status,
213
213
  statusText: request.statusText,
@@ -807,7 +807,7 @@ var _XMLHttpRequestInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
807
807
  logger.info('patching "XMLHttpRequest" module...');
808
808
  const PureXMLHttpRequest = globalThis.XMLHttpRequest;
809
809
  _outvariant.invariant.call(void 0,
810
- !PureXMLHttpRequest[_chunkCANMNIJAjs.IS_PATCHED_MODULE],
810
+ !PureXMLHttpRequest[_chunkBC2BLJQNjs.IS_PATCHED_MODULE],
811
811
  'Failed to patch the "XMLHttpRequest" module: already patched.'
812
812
  );
813
813
  globalThis.XMLHttpRequest = createXMLHttpRequestProxy({
@@ -818,13 +818,13 @@ var _XMLHttpRequestInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
818
818
  'native "XMLHttpRequest" module patched!',
819
819
  globalThis.XMLHttpRequest.name
820
820
  );
821
- Object.defineProperty(globalThis.XMLHttpRequest, _chunkCANMNIJAjs.IS_PATCHED_MODULE, {
821
+ Object.defineProperty(globalThis.XMLHttpRequest, _chunkBC2BLJQNjs.IS_PATCHED_MODULE, {
822
822
  enumerable: true,
823
823
  configurable: true,
824
824
  value: true
825
825
  });
826
826
  this.subscriptions.push(() => {
827
- Object.defineProperty(globalThis.XMLHttpRequest, _chunkCANMNIJAjs.IS_PATCHED_MODULE, {
827
+ Object.defineProperty(globalThis.XMLHttpRequest, _chunkBC2BLJQNjs.IS_PATCHED_MODULE, {
828
828
  value: void 0
829
829
  });
830
830
  globalThis.XMLHttpRequest = PureXMLHttpRequest;
@@ -841,4 +841,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
841
841
 
842
842
 
843
843
  exports.XMLHttpRequestInterceptor = XMLHttpRequestInterceptor;
844
- //# sourceMappingURL=chunk-UJNACJXF.js.map
844
+ //# sourceMappingURL=chunk-ZIT2QX7D.js.map
@@ -59,6 +59,10 @@ declare class FetchResponse extends Response {
59
59
  */
60
60
  static isResponseWithBody(status: number): boolean;
61
61
  static setUrl(url: string | undefined, response: Response): void;
62
+ /**
63
+ * Parses the given raw HTTP headers into a Fetch API `Headers` instance.
64
+ */
65
+ static parseRawHeaders(rawHeaders: Array<string>): Headers;
62
66
  constructor(body?: BodyInit | null, init?: FetchResponseInit);
63
67
  }
64
68
 
@@ -5,7 +5,7 @@ var _chunkLK6DILFKjs = require('./chunk-LK6DILFK.js');
5
5
 
6
6
 
7
7
 
8
- var _chunkCANMNIJAjs = require('./chunk-CANMNIJA.js');
8
+ var _chunkBC2BLJQNjs = require('./chunk-BC2BLJQN.js');
9
9
 
10
10
 
11
11
 
@@ -75,5 +75,5 @@ function getCleanUrl(url, isAbsolute = true) {
75
75
 
76
76
 
77
77
 
78
- exports.BatchInterceptor = BatchInterceptor; exports.FetchResponse = _chunkCANMNIJAjs.FetchResponse; exports.INTERNAL_REQUEST_ID_HEADER_NAME = _chunkTIPR373Rjs.INTERNAL_REQUEST_ID_HEADER_NAME; exports.IS_PATCHED_MODULE = _chunkCANMNIJAjs.IS_PATCHED_MODULE; exports.Interceptor = _chunkTIPR373Rjs.Interceptor; exports.InterceptorReadyState = _chunkTIPR373Rjs.InterceptorReadyState; exports.createRequestId = _chunkTIPR373Rjs.createRequestId; exports.decodeBuffer = _chunkLK6DILFKjs.decodeBuffer; exports.deleteGlobalSymbol = _chunkTIPR373Rjs.deleteGlobalSymbol; exports.encodeBuffer = _chunkLK6DILFKjs.encodeBuffer; exports.getCleanUrl = getCleanUrl; exports.getGlobalSymbol = _chunkTIPR373Rjs.getGlobalSymbol;
78
+ exports.BatchInterceptor = BatchInterceptor; exports.FetchResponse = _chunkBC2BLJQNjs.FetchResponse; exports.INTERNAL_REQUEST_ID_HEADER_NAME = _chunkTIPR373Rjs.INTERNAL_REQUEST_ID_HEADER_NAME; exports.IS_PATCHED_MODULE = _chunkBC2BLJQNjs.IS_PATCHED_MODULE; exports.Interceptor = _chunkTIPR373Rjs.Interceptor; exports.InterceptorReadyState = _chunkTIPR373Rjs.InterceptorReadyState; exports.createRequestId = _chunkTIPR373Rjs.createRequestId; exports.decodeBuffer = _chunkLK6DILFKjs.decodeBuffer; exports.deleteGlobalSymbol = _chunkTIPR373Rjs.deleteGlobalSymbol; exports.encodeBuffer = _chunkLK6DILFKjs.encodeBuffer; exports.getCleanUrl = getCleanUrl; exports.getGlobalSymbol = _chunkTIPR373Rjs.getGlobalSymbol;
79
79
  //# sourceMappingURL=index.js.map
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  FetchResponse,
7
7
  IS_PATCHED_MODULE
8
- } from "./chunk-F4BN745U.mjs";
8
+ } from "./chunk-5UK33FSU.mjs";
9
9
  import {
10
10
  INTERNAL_REQUEST_ID_HEADER_NAME,
11
11
  Interceptor,
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUJNACJXFjs = require('../../chunk-UJNACJXF.js');
3
+ var _chunkZIT2QX7Djs = require('../../chunk-ZIT2QX7D.js');
4
4
  require('../../chunk-LK6DILFK.js');
5
5
  require('../../chunk-FGSEOIC4.js');
6
- require('../../chunk-CANMNIJA.js');
6
+ require('../../chunk-BC2BLJQN.js');
7
7
  require('../../chunk-PFGO5BSM.js');
8
8
  require('../../chunk-TIPR373R.js');
9
9
 
10
10
 
11
- exports.XMLHttpRequestInterceptor = _chunkUJNACJXFjs.XMLHttpRequestInterceptor;
11
+ exports.XMLHttpRequestInterceptor = _chunkZIT2QX7Djs.XMLHttpRequestInterceptor;
12
12
  //# sourceMappingURL=index.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  XMLHttpRequestInterceptor
3
- } from "../../chunk-7SL7RZNU.mjs";
3
+ } from "../../chunk-DODHRDV6.mjs";
4
4
  import "../../chunk-6HYIRFX2.mjs";
5
5
  import "../../chunk-H5O73WD2.mjs";
6
- import "../../chunk-F4BN745U.mjs";
6
+ import "../../chunk-5UK33FSU.mjs";
7
7
  import "../../chunk-TX5GBTFY.mjs";
8
8
  import "../../chunk-QED3Q6Z2.mjs";
9
9
  export {
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk74GCTBGJjs = require('../../chunk-74GCTBGJ.js');
3
+ var _chunkQVOTKFTBjs = require('../../chunk-QVOTKFTB.js');
4
4
  require('../../chunk-FGSEOIC4.js');
5
- require('../../chunk-CANMNIJA.js');
5
+ require('../../chunk-BC2BLJQN.js');
6
6
  require('../../chunk-PFGO5BSM.js');
7
7
  require('../../chunk-TIPR373R.js');
8
8
 
9
9
 
10
- exports.FetchInterceptor = _chunk74GCTBGJjs.FetchInterceptor;
10
+ exports.FetchInterceptor = _chunkQVOTKFTBjs.FetchInterceptor;
11
11
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  FetchInterceptor
3
- } from "../../chunk-HER3NHBG.mjs";
3
+ } from "../../chunk-XTX2SIN6.mjs";
4
4
  import "../../chunk-H5O73WD2.mjs";
5
- import "../../chunk-F4BN745U.mjs";
5
+ import "../../chunk-5UK33FSU.mjs";
6
6
  import "../../chunk-TX5GBTFY.mjs";
7
7
  import "../../chunk-QED3Q6Z2.mjs";
8
8
  export {
@@ -1,19 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUJNACJXFjs = require('../chunk-UJNACJXF.js');
3
+ var _chunkZIT2QX7Djs = require('../chunk-ZIT2QX7D.js');
4
4
  require('../chunk-LK6DILFK.js');
5
5
 
6
6
 
7
- var _chunk74GCTBGJjs = require('../chunk-74GCTBGJ.js');
7
+ var _chunkQVOTKFTBjs = require('../chunk-QVOTKFTB.js');
8
8
  require('../chunk-FGSEOIC4.js');
9
- require('../chunk-CANMNIJA.js');
9
+ require('../chunk-BC2BLJQN.js');
10
10
  require('../chunk-PFGO5BSM.js');
11
11
  require('../chunk-TIPR373R.js');
12
12
 
13
13
  // src/presets/browser.ts
14
14
  var browser_default = [
15
- new (0, _chunk74GCTBGJjs.FetchInterceptor)(),
16
- new (0, _chunkUJNACJXFjs.XMLHttpRequestInterceptor)()
15
+ new (0, _chunkQVOTKFTBjs.FetchInterceptor)(),
16
+ new (0, _chunkZIT2QX7Djs.XMLHttpRequestInterceptor)()
17
17
  ];
18
18
 
19
19
 
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  XMLHttpRequestInterceptor
3
- } from "../chunk-7SL7RZNU.mjs";
3
+ } from "../chunk-DODHRDV6.mjs";
4
4
  import "../chunk-6HYIRFX2.mjs";
5
5
  import {
6
6
  FetchInterceptor
7
- } from "../chunk-HER3NHBG.mjs";
7
+ } from "../chunk-XTX2SIN6.mjs";
8
8
  import "../chunk-H5O73WD2.mjs";
9
- import "../chunk-F4BN745U.mjs";
9
+ import "../chunk-5UK33FSU.mjs";
10
10
  import "../chunk-TX5GBTFY.mjs";
11
11
  import "../chunk-QED3Q6Z2.mjs";
12
12
 
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkYMPTXPHDjs = require('./chunk-YMPTXPHD.js');
3
+ var _chunkYBN5MFAPjs = require('./chunk-YBN5MFAP.js');
4
4
 
5
5
 
6
- var _chunkZFSEKZ4Yjs = require('./chunk-ZFSEKZ4Y.js');
6
+ var _chunk3HCE66HZjs = require('./chunk-3HCE66HZ.js');
7
7
 
8
8
 
9
- var _chunkXP2VS4ILjs = require('./chunk-XP2VS4IL.js');
9
+ var _chunkLCA4FKWYjs = require('./chunk-LCA4FKWY.js');
10
10
  require('./chunk-LK6DILFK.js');
11
11
  require('./chunk-PFGO5BSM.js');
12
12
  require('./chunk-73NOP3T5.js');
@@ -17,16 +17,16 @@ var _chunk6L3PFBGTjs = require('./chunk-6L3PFBGT.js');
17
17
 
18
18
 
19
19
 
20
- var _chunkWGMDPBIXjs = require('./chunk-WGMDPBIX.js');
20
+ var _chunkWZTE4PCOjs = require('./chunk-WZTE4PCO.js');
21
21
 
22
22
  // src/RemoteHttpInterceptor.ts
23
- var RemoteHttpInterceptor = class extends _chunkYMPTXPHDjs.BatchInterceptor {
23
+ var RemoteHttpInterceptor = class extends _chunkYBN5MFAPjs.BatchInterceptor {
24
24
  constructor() {
25
25
  super({
26
26
  name: "remote-interceptor",
27
27
  interceptors: [
28
- new (0, _chunkZFSEKZ4Yjs.ClientRequestInterceptor)(),
29
- new (0, _chunkXP2VS4ILjs.XMLHttpRequestInterceptor)()
28
+ new (0, _chunk3HCE66HZjs.ClientRequestInterceptor)(),
29
+ new (0, _chunkLCA4FKWYjs.XMLHttpRequestInterceptor)()
30
30
  ]
31
31
  });
32
32
  }
@@ -61,7 +61,7 @@ var RemoteHttpInterceptor = class extends _chunkYMPTXPHDjs.BatchInterceptor {
61
61
  const responseInit = JSON.parse(
62
62
  serializedResponse
63
63
  );
64
- const mockedResponse = new (0, _chunkWGMDPBIXjs.FetchResponse)(responseInit.body, {
64
+ const mockedResponse = new (0, _chunkWZTE4PCOjs.FetchResponse)(responseInit.body, {
65
65
  url: request.url,
66
66
  status: responseInit.status,
67
67
  statusText: responseInit.statusText,
@@ -94,7 +94,7 @@ function requestReviver(key, value) {
94
94
  return value;
95
95
  }
96
96
  }
97
- var _RemoteHttpResolver = class extends _chunkWGMDPBIXjs.Interceptor {
97
+ var _RemoteHttpResolver = class extends _chunkWZTE4PCOjs.Interceptor {
98
98
  constructor(options) {
99
99
  super(_RemoteHttpResolver.symbol);
100
100
  this.process = options.process;
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  BatchInterceptor
3
- } from "./chunk-3CPL565R.mjs";
3
+ } from "./chunk-PJA4E426.mjs";
4
4
  import {
5
5
  ClientRequestInterceptor
6
- } from "./chunk-ZHMQHI2Z.mjs";
6
+ } from "./chunk-FWJSC2QD.mjs";
7
7
  import {
8
8
  XMLHttpRequestInterceptor
9
- } from "./chunk-WISH7OVU.mjs";
9
+ } from "./chunk-OMWE7UVM.mjs";
10
10
  import "./chunk-6HYIRFX2.mjs";
11
11
  import "./chunk-TX5GBTFY.mjs";
12
12
  import "./chunk-6YM4PLBI.mjs";
@@ -17,7 +17,7 @@ import {
17
17
  import {
18
18
  FetchResponse,
19
19
  Interceptor
20
- } from "./chunk-ELLF26MW.mjs";
20
+ } from "./chunk-I7HQIBT7.mjs";
21
21
 
22
22
  // src/RemoteHttpInterceptor.ts
23
23
  var RemoteHttpInterceptor = class extends BatchInterceptor {
@@ -10,7 +10,7 @@ var _chunk6L3PFBGTjs = require('./chunk-6L3PFBGT.js');
10
10
 
11
11
 
12
12
 
13
- var _chunkWGMDPBIXjs = require('./chunk-WGMDPBIX.js');
13
+ var _chunkWZTE4PCOjs = require('./chunk-WZTE4PCO.js');
14
14
 
15
15
  // src/interceptors/ClientRequest/index.ts
16
16
  var _http = require('http'); var _http2 = _interopRequireDefault(_http);
@@ -99,15 +99,6 @@ function baseUrlFromConnectionOptions(options) {
99
99
  return url;
100
100
  }
101
101
 
102
- // src/interceptors/Socket/utils/parseRawHeaders.ts
103
- function parseRawHeaders(rawHeaders) {
104
- const headers = new Headers();
105
- for (let line = 0; line < rawHeaders.length; line += 2) {
106
- headers.append(rawHeaders[line], rawHeaders[line + 1]);
107
- }
108
- return headers;
109
- }
110
-
111
102
  // src/interceptors/ClientRequest/utils/recordRawHeaders.ts
112
103
  var kRawHeaders = Symbol("kRawHeaders");
113
104
  var kRestorePatches = Symbol("kRestorePatches");
@@ -313,7 +304,7 @@ var MockHttpSocket = class extends MockSocket {
313
304
  this.shouldKeepAlive = shouldKeepAlive;
314
305
  const url = new URL(path, this.baseUrl);
315
306
  const method = ((_a = this.connectionOptions.method) == null ? void 0 : _a.toUpperCase()) || "GET";
316
- const headers = parseRawHeaders(rawHeaders);
307
+ const headers = _chunkWZTE4PCOjs.FetchResponse.parseRawHeaders(rawHeaders);
317
308
  const canHaveBody = method !== "GET" && method !== "HEAD";
318
309
  if (url.username || url.password) {
319
310
  if (!headers.has("authorization")) {
@@ -334,7 +325,7 @@ var MockHttpSocket = class extends MockSocket {
334
325
  }
335
326
  });
336
327
  }
337
- const requestId = _chunkWGMDPBIXjs.createRequestId.call(void 0, );
328
+ const requestId = _chunkWZTE4PCOjs.createRequestId.call(void 0, );
338
329
  this.request = new Request(url, {
339
330
  method,
340
331
  headers,
@@ -344,7 +335,7 @@ var MockHttpSocket = class extends MockSocket {
344
335
  body: canHaveBody ? _stream.Readable.toWeb(this.requestStream) : null
345
336
  });
346
337
  Reflect.set(this.request, kRequestId, requestId);
347
- if (this.request.headers.has(_chunkWGMDPBIXjs.INTERNAL_REQUEST_ID_HEADER_NAME)) {
338
+ if (this.request.headers.has(_chunkWZTE4PCOjs.INTERNAL_REQUEST_ID_HEADER_NAME)) {
348
339
  this.passthrough();
349
340
  return;
350
341
  }
@@ -355,8 +346,8 @@ var MockHttpSocket = class extends MockSocket {
355
346
  });
356
347
  };
357
348
  this.onResponseStart = (versionMajor, versionMinor, rawHeaders, method, url, status, statusText) => {
358
- const headers = parseRawHeaders(rawHeaders);
359
- const response = new (0, _chunkWGMDPBIXjs.FetchResponse)(
349
+ const headers = _chunkWZTE4PCOjs.FetchResponse.parseRawHeaders(rawHeaders);
350
+ const response = new (0, _chunkWZTE4PCOjs.FetchResponse)(
360
351
  /**
361
352
  * @note The Fetch API response instance exposed to the consumer
362
353
  * is created over the response stream of the HTTP parser. It is NOT
@@ -364,7 +355,7 @@ var MockHttpSocket = class extends MockSocket {
364
355
  * in response listener while the Socket instance delays the emission
365
356
  * of "end" and other events until those response listeners are finished.
366
357
  */
367
- _chunkWGMDPBIXjs.FetchResponse.isResponseWithBody(status) ? _stream.Readable.toWeb(
358
+ _chunkWZTE4PCOjs.FetchResponse.isResponseWithBody(status) ? _stream.Readable.toWeb(
368
359
  this.responseStream = new (0, _stream.Readable)({ read() {
369
360
  } })
370
361
  ) : null,
@@ -379,7 +370,7 @@ var MockHttpSocket = class extends MockSocket {
379
370
  this.request,
380
371
  "Failed to handle a response: request does not exist"
381
372
  );
382
- if (this.request.headers.has(_chunkWGMDPBIXjs.INTERNAL_REQUEST_ID_HEADER_NAME)) {
373
+ if (this.request.headers.has(_chunkWZTE4PCOjs.INTERNAL_REQUEST_ID_HEADER_NAME)) {
383
374
  return;
384
375
  }
385
376
  this.responseListenersPromise = this.onResponse({
@@ -460,7 +451,7 @@ var MockHttpSocket = class extends MockSocket {
460
451
  );
461
452
  const rawRequestHeaders = getRawFetchHeaders(this.request.headers);
462
453
  const requestHeadersString = rawRequestHeaders.filter(([name]) => {
463
- return name.toLowerCase() !== _chunkWGMDPBIXjs.INTERNAL_REQUEST_ID_HEADER_NAME;
454
+ return name.toLowerCase() !== _chunkWZTE4PCOjs.INTERNAL_REQUEST_ID_HEADER_NAME;
464
455
  }).map(([name, value]) => `${name}: ${value}`).join("\r\n");
465
456
  const headersChunk = `${chunkBeforeRequestHeaders}${requestHeadersString}${chunkAfterRequestHeaders}`;
466
457
  socket.write(headersChunk, encoding, callback);
@@ -639,12 +630,16 @@ var MockAgent = class extends _http2.default.Agent {
639
630
  this.onResponse = options.onResponse;
640
631
  }
641
632
  createConnection(options, callback) {
642
- const createConnection = this.customAgent instanceof _http2.default.Agent && this.customAgent.createConnection || super.createConnection;
633
+ const createConnection = this.customAgent instanceof _http2.default.Agent ? this.customAgent.createConnection : super.createConnection;
634
+ const createConnectionOptions = this.customAgent instanceof _http2.default.Agent ? {
635
+ ...options,
636
+ ...this.customAgent.options
637
+ } : options;
643
638
  const socket = new MockHttpSocket({
644
639
  connectionOptions: options,
645
640
  createConnection: createConnection.bind(
646
641
  this.customAgent || this,
647
- options,
642
+ createConnectionOptions,
648
643
  callback
649
644
  ),
650
645
  onRequest: this.onRequest.bind(this),
@@ -661,12 +656,16 @@ var MockHttpsAgent = class extends _https2.default.Agent {
661
656
  this.onResponse = options.onResponse;
662
657
  }
663
658
  createConnection(options, callback) {
664
- const createConnection = this.customAgent instanceof _https2.default.Agent && this.customAgent.createConnection || super.createConnection;
659
+ const createConnection = this.customAgent instanceof _https2.default.Agent ? this.customAgent.createConnection : super.createConnection;
660
+ const createConnectionOptions = this.customAgent instanceof _https2.default.Agent ? {
661
+ ...options,
662
+ ...this.customAgent.options
663
+ } : options;
665
664
  const socket = new MockHttpSocket({
666
665
  connectionOptions: options,
667
666
  createConnection: createConnection.bind(
668
667
  this.customAgent || this,
669
- options,
668
+ createConnectionOptions,
670
669
  callback
671
670
  ),
672
671
  onRequest: this.onRequest.bind(this),
@@ -912,7 +911,10 @@ function normalizeClientRequestArgs(defaultProtocol, args) {
912
911
  options.method = options.method || "GET";
913
912
  if (typeof options.agent === "undefined") {
914
913
  const agent = options.protocol === "https:" ? new (0, _https.Agent)({
915
- rejectUnauthorized: options.rejectUnauthorized
914
+ // Any other value other than false is considered as true, so we don't add this property if undefined.
915
+ ..."rejectUnauthorized" in options && {
916
+ rejectUnauthorized: options.rejectUnauthorized
917
+ }
916
918
  }) : new (0, _http.Agent)();
917
919
  options.agent = agent;
918
920
  logger3.info("resolved fallback agent:", agent);
@@ -934,7 +936,7 @@ function normalizeClientRequestArgs(defaultProtocol, args) {
934
936
  }
935
937
 
936
938
  // src/interceptors/ClientRequest/index.ts
937
- var _ClientRequestInterceptor = class extends _chunkWGMDPBIXjs.Interceptor {
939
+ var _ClientRequestInterceptor = class extends _chunkWZTE4PCOjs.Interceptor {
938
940
  constructor() {
939
941
  super(_ClientRequestInterceptor.symbol);
940
942
  this.onRequest = async ({
@@ -1059,4 +1061,4 @@ ClientRequestInterceptor.symbol = Symbol("client-request-interceptor");
1059
1061
 
1060
1062
 
1061
1063
  exports.ClientRequestInterceptor = ClientRequestInterceptor;
1062
- //# sourceMappingURL=chunk-ZFSEKZ4Y.js.map
1064
+ //# sourceMappingURL=chunk-3HCE66HZ.js.map