@whatwg-node/node-fetch 0.7.9-alpha-20250213122700-6a189724db9ab6211349779c44665b0b4f1006af → 0.7.9-rc-20250213120211-2e564250f0d6354be9db6c60c01427b07608eed5

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/Headers.js CHANGED
@@ -247,7 +247,7 @@ class PonyfillHeaders {
247
247
  record['set-cookie'] = this._setCookies;
248
248
  }
249
249
  else {
250
- record[key] = value?.includes(',') ? value.split(',').map(el => el.trim()) : value;
250
+ record[key] = value.includes(',') ? value.split(',').map(el => el.trim()) : value;
251
251
  }
252
252
  });
253
253
  return `Headers ${(0, node_util_1.inspect)(record)}`;
package/cjs/fetchCurl.js CHANGED
@@ -118,8 +118,7 @@ function fetchCurl(fetchRequest) {
118
118
  .filter(headerFilter => {
119
119
  if (headerFilter && !headerFilter.startsWith('HTTP/')) {
120
120
  if (fetchRequest.redirect === 'error' &&
121
- headerFilter.toLowerCase().includes('location') &&
122
- (0, utils_js_1.shouldRedirect)(status)) {
121
+ (headerFilter.includes('location') || headerFilter.includes('Location'))) {
123
122
  if (!stream.destroyed) {
124
123
  stream.resume();
125
124
  }
@@ -151,14 +150,7 @@ function fetchCurl(fetchRequest) {
151
150
  });
152
151
  }
153
152
  else {
154
- try {
155
- curlHandle.perform();
156
- }
157
- catch (e) {
158
- setImmediate(() => {
159
- curlHandle.perform();
160
- });
161
- }
153
+ curlHandle.perform();
162
154
  }
163
155
  return deferredPromise.promise;
164
156
  }
@@ -73,7 +73,7 @@ function fetchNodeHttp(fetchRequest) {
73
73
  default:
74
74
  outputStream = new node_stream_1.PassThrough();
75
75
  }
76
- if (nodeResponse.headers.location && (0, utils_js_1.shouldRedirect)(nodeResponse.statusCode)) {
76
+ if (nodeResponse.headers.location) {
77
77
  if (fetchRequest.redirect === 'error') {
78
78
  const redirectError = new Error('Redirects are not allowed');
79
79
  reject(redirectError);
package/cjs/utils.js CHANGED
@@ -7,7 +7,6 @@ exports.isArrayBufferView = isArrayBufferView;
7
7
  exports.isNodeReadable = isNodeReadable;
8
8
  exports.createDeferredPromise = createDeferredPromise;
9
9
  exports.isIterable = isIterable;
10
- exports.shouldRedirect = shouldRedirect;
11
10
  function isHeadersInstance(obj) {
12
11
  return obj?.forEach != null;
13
12
  }
@@ -89,6 +88,3 @@ function createDeferredPromise() {
89
88
  function isIterable(value) {
90
89
  return value?.[Symbol.iterator] != null;
91
90
  }
92
- function shouldRedirect(status) {
93
- return status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
94
- }
package/esm/Headers.js CHANGED
@@ -243,7 +243,7 @@ export class PonyfillHeaders {
243
243
  record['set-cookie'] = this._setCookies;
244
244
  }
245
245
  else {
246
- record[key] = value?.includes(',') ? value.split(',').map(el => el.trim()) : value;
246
+ record[key] = value.includes(',') ? value.split(',').map(el => el.trim()) : value;
247
247
  }
248
248
  });
249
249
  return `Headers ${inspect(record)}`;
package/esm/fetchCurl.js CHANGED
@@ -2,7 +2,7 @@ import { PassThrough, Readable } from 'node:stream';
2
2
  import { pipeline } from 'node:stream/promises';
3
3
  import { rootCertificates } from 'node:tls';
4
4
  import { PonyfillResponse } from './Response.js';
5
- import { createDeferredPromise, defaultHeadersSerializer, isNodeReadable, shouldRedirect, } from './utils.js';
5
+ import { createDeferredPromise, defaultHeadersSerializer, isNodeReadable } from './utils.js';
6
6
  export function fetchCurl(fetchRequest) {
7
7
  const { Curl, CurlFeature, CurlPause, CurlProgressFunc } = globalThis['libcurl'];
8
8
  const curlHandle = new Curl();
@@ -115,8 +115,7 @@ export function fetchCurl(fetchRequest) {
115
115
  .filter(headerFilter => {
116
116
  if (headerFilter && !headerFilter.startsWith('HTTP/')) {
117
117
  if (fetchRequest.redirect === 'error' &&
118
- headerFilter.toLowerCase().includes('location') &&
119
- shouldRedirect(status)) {
118
+ (headerFilter.includes('location') || headerFilter.includes('Location'))) {
120
119
  if (!stream.destroyed) {
121
120
  stream.resume();
122
121
  }
@@ -148,14 +147,7 @@ export function fetchCurl(fetchRequest) {
148
147
  });
149
148
  }
150
149
  else {
151
- try {
152
- curlHandle.perform();
153
- }
154
- catch (e) {
155
- setImmediate(() => {
156
- curlHandle.perform();
157
- });
158
- }
150
+ curlHandle.perform();
159
151
  }
160
152
  return deferredPromise.promise;
161
153
  }
@@ -6,7 +6,7 @@ import { createBrotliDecompress, createGunzip, createInflate, createInflateRaw }
6
6
  import { PonyfillRequest } from './Request.js';
7
7
  import { PonyfillResponse } from './Response.js';
8
8
  import { PonyfillURL } from './URL.js';
9
- import { getHeadersObj, isNodeReadable, shouldRedirect } from './utils.js';
9
+ import { getHeadersObj, isNodeReadable } from './utils.js';
10
10
  function getRequestFnForProtocol(url) {
11
11
  if (url.startsWith('http:')) {
12
12
  return httpRequest;
@@ -70,7 +70,7 @@ export function fetchNodeHttp(fetchRequest) {
70
70
  default:
71
71
  outputStream = new PassThrough();
72
72
  }
73
- if (nodeResponse.headers.location && shouldRedirect(nodeResponse.statusCode)) {
73
+ if (nodeResponse.headers.location) {
74
74
  if (fetchRequest.redirect === 'error') {
75
75
  const redirectError = new Error('Redirects are not allowed');
76
76
  reject(redirectError);
package/esm/utils.js CHANGED
@@ -79,6 +79,3 @@ export function createDeferredPromise() {
79
79
  export function isIterable(value) {
80
80
  return value?.[Symbol.iterator] != null;
81
81
  }
82
- export function shouldRedirect(status) {
83
- return status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
84
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.7.9-alpha-20250213122700-6a189724db9ab6211349779c44665b0b4f1006af",
3
+ "version": "0.7.9-rc-20250213120211-2e564250f0d6354be9db6c60c01427b07608eed5",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
@@ -11,4 +11,3 @@ export interface DeferredPromise<T = void> {
11
11
  }
12
12
  export declare function createDeferredPromise<T = void>(): DeferredPromise<T>;
13
13
  export declare function isIterable(value: any): value is Iterable<unknown>;
14
- export declare function shouldRedirect(status?: number): boolean;
@@ -11,4 +11,3 @@ export interface DeferredPromise<T = void> {
11
11
  }
12
12
  export declare function createDeferredPromise<T = void>(): DeferredPromise<T>;
13
13
  export declare function isIterable(value: any): value is Iterable<unknown>;
14
- export declare function shouldRedirect(status?: number): boolean;