@whatwg-node/node-fetch 0.5.25-alpha-20240822094535-27aedb66e4a50013166df3781e63717a996f07a8 → 0.5.25-alpha-20240822095820-b39bfa0ecca2c39a9952bd1ffebf8ab8ef2f2772

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/cjs/Request.js CHANGED
@@ -56,13 +56,13 @@ class PonyfillRequest extends Body_js_1.PonyfillBody {
56
56
  }
57
57
  if (requestInit?.agent != null) {
58
58
  if (requestInit.agent === false) {
59
- this._agent = false;
59
+ this.agent = false;
60
60
  }
61
61
  else if (this.url.startsWith('http:/') && requestInit.agent instanceof http_1.Agent) {
62
- this._agent = requestInit?.agent;
62
+ this.agent = requestInit.agent;
63
63
  }
64
64
  else if (this.url.startsWith('https:/') && requestInit.agent instanceof https_1.Agent) {
65
- this._agent = requestInit?.agent;
65
+ this.agent = requestInit.agent;
66
66
  }
67
67
  }
68
68
  }
@@ -81,22 +81,7 @@ class PonyfillRequest extends Body_js_1.PonyfillBody {
81
81
  referrerPolicy;
82
82
  url;
83
83
  duplex;
84
- _agent;
85
- get agent() {
86
- if (this._agent != null) {
87
- return this._agent;
88
- }
89
- // Disable agent when running in jest
90
- if (globalThis['libcurl'] || typeof jest === 'object') {
91
- return false;
92
- }
93
- if (this.url.startsWith('http:')) {
94
- return http_1.globalAgent;
95
- }
96
- else if (this.url.startsWith('https:')) {
97
- return https_1.globalAgent;
98
- }
99
- }
84
+ agent;
100
85
  _signal;
101
86
  get signal() {
102
87
  // Create a new signal only if needed
package/cjs/fetch.js CHANGED
@@ -71,7 +71,7 @@ function fetchPonyfill(info, init) {
71
71
  const response = getResponseForBlob(fetchRequest.url);
72
72
  return (0, utils_js_1.fakePromise)(response);
73
73
  }
74
- if (globalThis.libcurl) {
74
+ if (globalThis.libcurl && !fetchRequest.agent) {
75
75
  return (0, fetchCurl_js_1.fetchCurl)(fetchRequest);
76
76
  }
77
77
  return (0, fetchNodeHttp_js_1.fetchNodeHttp)(fetchRequest);
package/esm/Request.js CHANGED
@@ -1,5 +1,5 @@
1
- import { Agent as HTTPAgent, globalAgent as httpGlobalAgent } from 'http';
2
- import { Agent as HTTPSAgent, globalAgent as httpsGlobalAgent } from 'https';
1
+ import { Agent as HTTPAgent } from 'http';
2
+ import { Agent as HTTPSAgent } from 'https';
3
3
  import { PonyfillBody } from './Body.js';
4
4
  import { isHeadersLike, PonyfillHeaders } from './Headers.js';
5
5
  function isRequest(input) {
@@ -53,13 +53,13 @@ export class PonyfillRequest extends PonyfillBody {
53
53
  }
54
54
  if (requestInit?.agent != null) {
55
55
  if (requestInit.agent === false) {
56
- this._agent = false;
56
+ this.agent = false;
57
57
  }
58
58
  else if (this.url.startsWith('http:/') && requestInit.agent instanceof HTTPAgent) {
59
- this._agent = requestInit?.agent;
59
+ this.agent = requestInit.agent;
60
60
  }
61
61
  else if (this.url.startsWith('https:/') && requestInit.agent instanceof HTTPSAgent) {
62
- this._agent = requestInit?.agent;
62
+ this.agent = requestInit.agent;
63
63
  }
64
64
  }
65
65
  }
@@ -78,22 +78,7 @@ export class PonyfillRequest extends PonyfillBody {
78
78
  referrerPolicy;
79
79
  url;
80
80
  duplex;
81
- _agent;
82
- get agent() {
83
- if (this._agent != null) {
84
- return this._agent;
85
- }
86
- // Disable agent when running in jest
87
- if (globalThis['libcurl'] || typeof jest === 'object') {
88
- return false;
89
- }
90
- if (this.url.startsWith('http:')) {
91
- return httpGlobalAgent;
92
- }
93
- else if (this.url.startsWith('https:')) {
94
- return httpsGlobalAgent;
95
- }
96
- }
81
+ agent;
97
82
  _signal;
98
83
  get signal() {
99
84
  // Create a new signal only if needed
package/esm/fetch.js CHANGED
@@ -68,7 +68,7 @@ export function fetchPonyfill(info, init) {
68
68
  const response = getResponseForBlob(fetchRequest.url);
69
69
  return fakePromise(response);
70
70
  }
71
- if (globalThis.libcurl) {
71
+ if (globalThis.libcurl && !fetchRequest.agent) {
72
72
  return fetchCurl(fetchRequest);
73
73
  }
74
74
  return fetchNodeHttp(fetchRequest);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.5.25-alpha-20240822094535-27aedb66e4a50013166df3781e63717a996f07a8",
3
+ "version": "0.5.25-alpha-20240822095820-b39bfa0ecca2c39a9952bd1ffebf8ab8ef2f2772",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
@@ -27,8 +27,7 @@ export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> im
27
27
  referrerPolicy: ReferrerPolicy;
28
28
  url: string;
29
29
  duplex: 'half' | 'full';
30
- private _agent;
31
- get agent(): false | HTTPAgent | undefined;
30
+ agent: HTTPAgent | HTTPSAgent | false | undefined;
32
31
  private _signal;
33
32
  get signal(): AbortSignal;
34
33
  clone(): PonyfillRequest<TJSON>;
@@ -27,8 +27,7 @@ export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> im
27
27
  referrerPolicy: ReferrerPolicy;
28
28
  url: string;
29
29
  duplex: 'half' | 'full';
30
- private _agent;
31
- get agent(): false | HTTPAgent | undefined;
30
+ agent: HTTPAgent | HTTPSAgent | false | undefined;
32
31
  private _signal;
33
32
  get signal(): AbortSignal;
34
33
  clone(): PonyfillRequest<TJSON>;