@whatwg-node/node-fetch 0.5.19 → 0.5.20-rc-20240730145649-3d326c64a43b48290c8c30454172053ce6c74732
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 +11 -1
- package/cjs/fetchCurl.js +2 -1
- package/esm/Request.js +13 -3
- package/esm/fetchCurl.js +2 -1
- package/package.json +1 -1
package/cjs/Request.js
CHANGED
@@ -75,7 +75,17 @@ class PonyfillRequest extends Body_js_1.PonyfillBody {
|
|
75
75
|
this.contentLength = parseInt(contentLengthInHeaders, 10);
|
76
76
|
}
|
77
77
|
}
|
78
|
-
|
78
|
+
if (requestInit?.agent != null) {
|
79
|
+
if (requestInit?.agent === false) {
|
80
|
+
this._agent = false;
|
81
|
+
}
|
82
|
+
if (this.url.startsWith('http:/') && this._agent instanceof http_1.Agent) {
|
83
|
+
this._agent = requestInit?.agent;
|
84
|
+
}
|
85
|
+
else if (this.url.startsWith('https:/') && this._agent instanceof https_1.Agent) {
|
86
|
+
this._agent = requestInit?.agent;
|
87
|
+
}
|
88
|
+
}
|
79
89
|
}
|
80
90
|
headersSerializer;
|
81
91
|
cache;
|
package/cjs/fetchCurl.js
CHANGED
@@ -114,7 +114,8 @@ function fetchCurl(fetchRequest) {
|
|
114
114
|
const ponyfillResponse = new Response_js_1.PonyfillResponse(outputStream, {
|
115
115
|
status,
|
116
116
|
headers: headersInit,
|
117
|
-
url: fetchRequest.url,
|
117
|
+
url: curlHandle.getInfo(Curl.info.REDIRECT_URL)?.toString() || fetchRequest.url,
|
118
|
+
redirected: Number(curlHandle.getInfo(Curl.info.REDIRECT_COUNT)) > 0,
|
118
119
|
});
|
119
120
|
resolve(ponyfillResponse);
|
120
121
|
streamResolved = outputStream;
|
package/esm/Request.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { globalAgent as httpGlobalAgent } from 'http';
|
2
|
-
import { globalAgent as httpsGlobalAgent } from 'https';
|
1
|
+
import { Agent as HTTPAgent, globalAgent as httpGlobalAgent } from 'http';
|
2
|
+
import { Agent as HTTPSAgent, globalAgent as httpsGlobalAgent } from 'https';
|
3
3
|
import { PonyfillBody } from './Body.js';
|
4
4
|
import { isHeadersLike, PonyfillHeaders } from './Headers.js';
|
5
5
|
function isRequest(input) {
|
@@ -72,7 +72,17 @@ export class PonyfillRequest extends PonyfillBody {
|
|
72
72
|
this.contentLength = parseInt(contentLengthInHeaders, 10);
|
73
73
|
}
|
74
74
|
}
|
75
|
-
|
75
|
+
if (requestInit?.agent != null) {
|
76
|
+
if (requestInit?.agent === false) {
|
77
|
+
this._agent = false;
|
78
|
+
}
|
79
|
+
if (this.url.startsWith('http:/') && this._agent instanceof HTTPAgent) {
|
80
|
+
this._agent = requestInit?.agent;
|
81
|
+
}
|
82
|
+
else if (this.url.startsWith('https:/') && this._agent instanceof HTTPSAgent) {
|
83
|
+
this._agent = requestInit?.agent;
|
84
|
+
}
|
85
|
+
}
|
76
86
|
}
|
77
87
|
headersSerializer;
|
78
88
|
cache;
|
package/esm/fetchCurl.js
CHANGED
@@ -111,7 +111,8 @@ export function fetchCurl(fetchRequest) {
|
|
111
111
|
const ponyfillResponse = new PonyfillResponse(outputStream, {
|
112
112
|
status,
|
113
113
|
headers: headersInit,
|
114
|
-
url: fetchRequest.url,
|
114
|
+
url: curlHandle.getInfo(Curl.info.REDIRECT_URL)?.toString() || fetchRequest.url,
|
115
|
+
redirected: Number(curlHandle.getInfo(Curl.info.REDIRECT_COUNT)) > 0,
|
115
116
|
});
|
116
117
|
resolve(ponyfillResponse);
|
117
118
|
streamResolved = outputStream;
|
package/package.json
CHANGED