@whatwg-node/node-fetch 0.7.22-alpha-20250527014600-33a0363f582926116cdd12dd455c7db8f571dbfe → 0.7.22-alpha-20250527020114-bf7a9c1c4bf32e1ca6edd3faf2d7a81370ded65c

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/Body.js CHANGED
@@ -357,11 +357,10 @@ function processBodyInit(bodyInit) {
357
357
  };
358
358
  }
359
359
  if (typeof bodyInit === 'string') {
360
- const contentLength = node_buffer_1.Buffer.byteLength(bodyInit);
361
360
  return {
362
361
  bodyType: BodyInitType.String,
363
- contentType: 'text/plain;charset=UTF-8',
364
- contentLength,
362
+ contentType: null,
363
+ contentLength: null,
365
364
  bodyFactory() {
366
365
  const readable = node_stream_1.Readable.from(node_buffer_1.Buffer.from(bodyInit, 'utf-8'));
367
366
  return new ReadableStream_js_1.PonyfillReadableStream(readable);
package/cjs/Response.js CHANGED
@@ -4,7 +4,6 @@ exports.PonyfillResponse = void 0;
4
4
  const node_http_1 = require("node:http");
5
5
  const Body_js_1 = require("./Body.js");
6
6
  const Headers_js_1 = require("./Headers.js");
7
- const JSON_CONTENT_TYPE = 'application/json; charset=utf-8';
8
7
  class PonyfillResponse extends Body_js_1.PonyfillBody {
9
8
  headers;
10
9
  constructor(body, init) {
@@ -50,57 +49,6 @@ class PonyfillResponse extends Body_js_1.PonyfillBody {
50
49
  }
51
50
  static json(data, init) {
52
51
  const bodyInit = JSON.stringify(data);
53
- if (!init) {
54
- init = {
55
- headers: {
56
- 'content-type': JSON_CONTENT_TYPE,
57
- 'content-length': Buffer.byteLength(bodyInit).toString(),
58
- },
59
- };
60
- }
61
- else if (!init.headers) {
62
- init.headers = {
63
- 'content-type': JSON_CONTENT_TYPE,
64
- 'content-length': Buffer.byteLength(bodyInit).toString(),
65
- };
66
- }
67
- else if ((0, Headers_js_1.isHeadersLike)(init.headers)) {
68
- if (!init.headers.has('content-type')) {
69
- init.headers.set('content-type', JSON_CONTENT_TYPE);
70
- }
71
- if (!init.headers.has('content-length')) {
72
- init.headers.set('content-length', Buffer.byteLength(bodyInit).toString());
73
- }
74
- }
75
- else if (Array.isArray(init.headers)) {
76
- let contentTypeExists = false;
77
- let contentLengthExists = false;
78
- for (const [key] of init.headers) {
79
- if (contentLengthExists && contentTypeExists) {
80
- break;
81
- }
82
- if (!contentTypeExists && key.toLowerCase() === 'content-type') {
83
- contentTypeExists = true;
84
- }
85
- else if (!contentLengthExists && key.toLowerCase() === 'content-length') {
86
- contentLengthExists = true;
87
- }
88
- }
89
- if (!contentTypeExists) {
90
- init.headers.push(['content-type', JSON_CONTENT_TYPE]);
91
- }
92
- if (!contentLengthExists) {
93
- init.headers.push(['content-length', Buffer.byteLength(bodyInit).toString()]);
94
- }
95
- }
96
- else if (typeof init.headers === 'object') {
97
- if (init.headers?.['content-type'] == null) {
98
- init.headers['content-type'] = JSON_CONTENT_TYPE;
99
- }
100
- if (init.headers?.['content-length'] == null) {
101
- init.headers['content-length'] = Buffer.byteLength(bodyInit).toString();
102
- }
103
- }
104
52
  return new PonyfillResponse(bodyInit, init);
105
53
  }
106
54
  [Symbol.toStringTag] = 'Response';
package/esm/Body.js CHANGED
@@ -353,11 +353,10 @@ function processBodyInit(bodyInit) {
353
353
  };
354
354
  }
355
355
  if (typeof bodyInit === 'string') {
356
- const contentLength = Buffer.byteLength(bodyInit);
357
356
  return {
358
357
  bodyType: BodyInitType.String,
359
- contentType: 'text/plain;charset=UTF-8',
360
- contentLength,
358
+ contentType: null,
359
+ contentLength: null,
361
360
  bodyFactory() {
362
361
  const readable = Readable.from(Buffer.from(bodyInit, 'utf-8'));
363
362
  return new PonyfillReadableStream(readable);
package/esm/Response.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { STATUS_CODES } from 'node:http';
2
2
  import { PonyfillBody } from './Body.js';
3
3
  import { isHeadersLike, PonyfillHeaders } from './Headers.js';
4
- const JSON_CONTENT_TYPE = 'application/json; charset=utf-8';
5
4
  export class PonyfillResponse extends PonyfillBody {
6
5
  headers;
7
6
  constructor(body, init) {
@@ -47,57 +46,6 @@ export class PonyfillResponse extends PonyfillBody {
47
46
  }
48
47
  static json(data, init) {
49
48
  const bodyInit = JSON.stringify(data);
50
- if (!init) {
51
- init = {
52
- headers: {
53
- 'content-type': JSON_CONTENT_TYPE,
54
- 'content-length': Buffer.byteLength(bodyInit).toString(),
55
- },
56
- };
57
- }
58
- else if (!init.headers) {
59
- init.headers = {
60
- 'content-type': JSON_CONTENT_TYPE,
61
- 'content-length': Buffer.byteLength(bodyInit).toString(),
62
- };
63
- }
64
- else if (isHeadersLike(init.headers)) {
65
- if (!init.headers.has('content-type')) {
66
- init.headers.set('content-type', JSON_CONTENT_TYPE);
67
- }
68
- if (!init.headers.has('content-length')) {
69
- init.headers.set('content-length', Buffer.byteLength(bodyInit).toString());
70
- }
71
- }
72
- else if (Array.isArray(init.headers)) {
73
- let contentTypeExists = false;
74
- let contentLengthExists = false;
75
- for (const [key] of init.headers) {
76
- if (contentLengthExists && contentTypeExists) {
77
- break;
78
- }
79
- if (!contentTypeExists && key.toLowerCase() === 'content-type') {
80
- contentTypeExists = true;
81
- }
82
- else if (!contentLengthExists && key.toLowerCase() === 'content-length') {
83
- contentLengthExists = true;
84
- }
85
- }
86
- if (!contentTypeExists) {
87
- init.headers.push(['content-type', JSON_CONTENT_TYPE]);
88
- }
89
- if (!contentLengthExists) {
90
- init.headers.push(['content-length', Buffer.byteLength(bodyInit).toString()]);
91
- }
92
- }
93
- else if (typeof init.headers === 'object') {
94
- if (init.headers?.['content-type'] == null) {
95
- init.headers['content-type'] = JSON_CONTENT_TYPE;
96
- }
97
- if (init.headers?.['content-length'] == null) {
98
- init.headers['content-length'] = Buffer.byteLength(bodyInit).toString();
99
- }
100
- }
101
49
  return new PonyfillResponse(bodyInit, init);
102
50
  }
103
51
  [Symbol.toStringTag] = 'Response';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.7.22-alpha-20250527014600-33a0363f582926116cdd12dd455c7db8f571dbfe",
3
+ "version": "0.7.22-alpha-20250527020114-bf7a9c1c4bf32e1ca6edd3faf2d7a81370ded65c",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {