@whatwg-node/node-fetch 0.3.4-rc-20230321094246-110a38a → 0.3.5-alpha-20230417094550-b36ed97

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
@@ -4,6 +4,7 @@ exports.PonyfillRequest = void 0;
4
4
  const AbortController_js_1 = require("./AbortController.js");
5
5
  const Body_js_1 = require("./Body.js");
6
6
  const Headers_js_1 = require("./Headers.js");
7
+ const utils_js_1 = require("./utils.js");
7
8
  function isRequest(input) {
8
9
  return input[Symbol.toStringTag] === 'Request';
9
10
  }
@@ -42,6 +43,7 @@ class PonyfillRequest extends Body_js_1.PonyfillBody {
42
43
  this.referrer = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrer) || 'about:client';
43
44
  this.referrerPolicy = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrerPolicy) || 'no-referrer';
44
45
  this.signal = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.signal) || new AbortController_js_1.PonyfillAbortController().signal;
46
+ this.headersSerializer = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.headersSerializer) || utils_js_1.getHeadersObj;
45
47
  this.url = url || '';
46
48
  const contentTypeInHeaders = this.headers.get('content-type');
47
49
  if (!contentTypeInHeaders) {
package/cjs/fetch.js CHANGED
@@ -72,7 +72,8 @@ function fetchPonyfill(info, init) {
72
72
  ? fetchRequest.body
73
73
  : stream_1.Readable.from(fetchRequest.body)
74
74
  : null);
75
- const nodeHeaders = (0, utils_js_1.getHeadersObj)(fetchRequest.headers);
75
+ const headersSerializer = fetchRequest.headersSerializer || utils_js_1.getHeadersObj;
76
+ const nodeHeaders = headersSerializer(fetchRequest.headers);
76
77
  const abortListener = function abortListener(event) {
77
78
  nodeRequest.destroy();
78
79
  const reason = event.detail;
package/esm/Request.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { PonyfillAbortController } from './AbortController.js';
2
2
  import { PonyfillBody } from './Body.js';
3
3
  import { PonyfillHeaders } from './Headers.js';
4
+ import { getHeadersObj } from './utils.js';
4
5
  function isRequest(input) {
5
6
  return input[Symbol.toStringTag] === 'Request';
6
7
  }
@@ -39,6 +40,7 @@ export class PonyfillRequest extends PonyfillBody {
39
40
  this.referrer = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrer) || 'about:client';
40
41
  this.referrerPolicy = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrerPolicy) || 'no-referrer';
41
42
  this.signal = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.signal) || new PonyfillAbortController().signal;
43
+ this.headersSerializer = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.headersSerializer) || getHeadersObj;
42
44
  this.url = url || '';
43
45
  const contentTypeInHeaders = this.headers.get('content-type');
44
46
  if (!contentTypeInHeaders) {
package/esm/fetch.js CHANGED
@@ -69,7 +69,8 @@ export function fetchPonyfill(info, init) {
69
69
  ? fetchRequest.body
70
70
  : Readable.from(fetchRequest.body)
71
71
  : null);
72
- const nodeHeaders = getHeadersObj(fetchRequest.headers);
72
+ const headersSerializer = fetchRequest.headersSerializer || getHeadersObj;
73
+ const nodeHeaders = headersSerializer(fetchRequest.headers);
73
74
  const abortListener = function abortListener(event) {
74
75
  nodeRequest.destroy();
75
76
  const reason = event.detail;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.3.4-rc-20230321094246-110a38a",
3
+ "version": "0.3.5-alpha-20230417094550-b36ed97",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
@@ -3,9 +3,12 @@ import { PonyfillHeadersInit } from './Headers.cjs';
3
3
  export type RequestPonyfillInit = PonyfillBodyOptions & Omit<RequestInit, 'body' | 'headers'> & {
4
4
  body?: BodyPonyfillInit | null;
5
5
  headers?: PonyfillHeadersInit;
6
+ headersSerializer?: HeadersSerializer;
6
7
  };
8
+ type HeadersSerializer = (headers: Headers) => Record<string, string>;
7
9
  export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> implements Request {
8
10
  constructor(input: RequestInfo | URL, options?: RequestPonyfillInit);
11
+ headersSerializer: HeadersSerializer;
9
12
  cache: RequestCache;
10
13
  credentials: RequestCredentials;
11
14
  destination: RequestDestination;
@@ -22,3 +25,4 @@ export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> im
22
25
  signal: AbortSignal;
23
26
  clone(): Request;
24
27
  }
28
+ export {};
@@ -3,9 +3,12 @@ import { PonyfillHeadersInit } from './Headers.js';
3
3
  export type RequestPonyfillInit = PonyfillBodyOptions & Omit<RequestInit, 'body' | 'headers'> & {
4
4
  body?: BodyPonyfillInit | null;
5
5
  headers?: PonyfillHeadersInit;
6
+ headersSerializer?: HeadersSerializer;
6
7
  };
8
+ type HeadersSerializer = (headers: Headers) => Record<string, string>;
7
9
  export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> implements Request {
8
10
  constructor(input: RequestInfo | URL, options?: RequestPonyfillInit);
11
+ headersSerializer: HeadersSerializer;
9
12
  cache: RequestCache;
10
13
  credentials: RequestCredentials;
11
14
  destination: RequestDestination;
@@ -22,3 +25,4 @@ export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> im
22
25
  signal: AbortSignal;
23
26
  clone(): Request;
24
27
  }
28
+ export {};