@whatwg-node/node-fetch 0.5.7-alpha-20240229132341-1e3c1f24effefed571297b2c5001e44cfaefbf60 → 0.5.7-alpha-20240301160930-a3ba2c27f4f23de94960f603ed19b24325dfe24d

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/fetchCurl.js CHANGED
@@ -88,11 +88,22 @@ function fetchCurl(fetchRequest) {
88
88
  return false;
89
89
  });
90
90
  const headersInit = headersFlat.map(headerFlat => headerFlat.split(/:\s(.+)/).slice(0, 2));
91
- resolve(new Response_js_1.PonyfillResponse(stream.pipe(new node_stream_1.PassThrough()), {
91
+ const pipedStream = stream.pipe(new node_stream_1.PassThrough());
92
+ pipedStream.on('pause', () => {
93
+ stream.pause();
94
+ });
95
+ pipedStream.on('resume', () => {
96
+ stream.resume();
97
+ });
98
+ pipedStream.on('close', () => {
99
+ stream.destroy();
100
+ });
101
+ const ponyfillResponse = new Response_js_1.PonyfillResponse(pipedStream, {
92
102
  status,
93
103
  headers: headersInit,
94
104
  url: fetchRequest.url,
95
- }));
105
+ });
106
+ resolve(ponyfillResponse);
96
107
  streamResolved = stream;
97
108
  });
98
109
  curlHandle.perform();
@@ -36,7 +36,7 @@ function fetchNodeHttp(fetchRequest) {
36
36
  agent: fetchRequest.agent,
37
37
  });
38
38
  nodeRequest.once('response', nodeResponse => {
39
- let responseBody = nodeResponse.pipe(new stream_1.PassThrough());
39
+ let responseBody = nodeResponse;
40
40
  const contentEncoding = nodeResponse.headers['content-encoding'];
41
41
  switch (contentEncoding) {
42
42
  case 'x-gzip':
@@ -69,6 +69,18 @@ function fetchNodeHttp(fetchRequest) {
69
69
  return;
70
70
  }
71
71
  }
72
+ if (responseBody === nodeResponse) {
73
+ responseBody = nodeResponse.pipe(new stream_1.PassThrough());
74
+ responseBody.on('pause', () => {
75
+ nodeResponse.pause();
76
+ });
77
+ responseBody.on('resume', () => {
78
+ nodeResponse.resume();
79
+ });
80
+ responseBody.on('close', () => {
81
+ nodeResponse.destroy();
82
+ });
83
+ }
72
84
  const ponyfillResponse = new Response_js_1.PonyfillResponse(responseBody, {
73
85
  status: nodeResponse.statusCode,
74
86
  statusText: nodeResponse.statusMessage,
package/esm/fetchCurl.js CHANGED
@@ -85,11 +85,22 @@ export function fetchCurl(fetchRequest) {
85
85
  return false;
86
86
  });
87
87
  const headersInit = headersFlat.map(headerFlat => headerFlat.split(/:\s(.+)/).slice(0, 2));
88
- resolve(new PonyfillResponse(stream.pipe(new PassThrough()), {
88
+ const pipedStream = stream.pipe(new PassThrough());
89
+ pipedStream.on('pause', () => {
90
+ stream.pause();
91
+ });
92
+ pipedStream.on('resume', () => {
93
+ stream.resume();
94
+ });
95
+ pipedStream.on('close', () => {
96
+ stream.destroy();
97
+ });
98
+ const ponyfillResponse = new PonyfillResponse(pipedStream, {
89
99
  status,
90
100
  headers: headersInit,
91
101
  url: fetchRequest.url,
92
- }));
102
+ });
103
+ resolve(ponyfillResponse);
93
104
  streamResolved = stream;
94
105
  });
95
106
  curlHandle.perform();
@@ -33,7 +33,7 @@ export function fetchNodeHttp(fetchRequest) {
33
33
  agent: fetchRequest.agent,
34
34
  });
35
35
  nodeRequest.once('response', nodeResponse => {
36
- let responseBody = nodeResponse.pipe(new PassThrough());
36
+ let responseBody = nodeResponse;
37
37
  const contentEncoding = nodeResponse.headers['content-encoding'];
38
38
  switch (contentEncoding) {
39
39
  case 'x-gzip':
@@ -66,6 +66,18 @@ export function fetchNodeHttp(fetchRequest) {
66
66
  return;
67
67
  }
68
68
  }
69
+ if (responseBody === nodeResponse) {
70
+ responseBody = nodeResponse.pipe(new PassThrough());
71
+ responseBody.on('pause', () => {
72
+ nodeResponse.pause();
73
+ });
74
+ responseBody.on('resume', () => {
75
+ nodeResponse.resume();
76
+ });
77
+ responseBody.on('close', () => {
78
+ nodeResponse.destroy();
79
+ });
80
+ }
69
81
  const ponyfillResponse = new PonyfillResponse(responseBody, {
70
82
  status: nodeResponse.statusCode,
71
83
  statusText: nodeResponse.statusMessage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.5.7-alpha-20240229132341-1e3c1f24effefed571297b2c5001e44cfaefbf60",
3
+ "version": "0.5.7-alpha-20240301160930-a3ba2c27f4f23de94960f603ed19b24325dfe24d",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {