@whatwg-node/node-fetch 0.7.15-alpha-20250324173553-1c494d807956f93726a5088943b9a352670208b0 → 0.7.15-alpha-20250324192010-b283f7e2f0fd92fdb6ab59d74fe78de9fa4dbd78
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 +5 -0
- package/cjs/Request.js +1 -1
- package/esm/Body.js +6 -1
- package/esm/Request.js +1 -1
- package/package.json +1 -1
- package/typings/Body.d.cts +1 -0
- package/typings/Body.d.ts +1 -0
package/cjs/Body.js
CHANGED
@@ -29,9 +29,11 @@ class PonyfillBody {
|
|
29
29
|
bodyUsed = false;
|
30
30
|
contentType = null;
|
31
31
|
contentLength = null;
|
32
|
+
signal = null;
|
32
33
|
constructor(bodyInit, options = {}) {
|
33
34
|
this.bodyInit = bodyInit;
|
34
35
|
this.options = options;
|
36
|
+
this.signal = options.signal || null;
|
35
37
|
const { bodyFactory, contentType, contentLength, bodyType, buffer } = processBodyInit(bodyInit, options?.signal);
|
36
38
|
this._bodyFactory = bodyFactory;
|
37
39
|
this.contentType = contentType;
|
@@ -52,6 +54,9 @@ class PonyfillBody {
|
|
52
54
|
}
|
53
55
|
const body = this._bodyFactory();
|
54
56
|
this._generatedBody = body;
|
57
|
+
if (body?.readable && this.signal) {
|
58
|
+
(0, node_stream_1.addAbortSignal)(this.signal, body.readable);
|
59
|
+
}
|
55
60
|
return body;
|
56
61
|
}
|
57
62
|
handleContentLengthHeader(forceSet = false) {
|
package/cjs/Request.js
CHANGED
@@ -41,7 +41,7 @@ class PonyfillRequest extends Body_js_1.PonyfillBody {
|
|
41
41
|
bodyInit = options.body || null;
|
42
42
|
requestInit = options;
|
43
43
|
}
|
44
|
-
super(bodyInit,
|
44
|
+
super(bodyInit, requestInit);
|
45
45
|
this._url = _url;
|
46
46
|
this._parsedUrl = _parsedUrl;
|
47
47
|
this.cache = requestInit?.cache || 'default';
|
package/esm/Body.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
2
2
|
import { Buffer } from 'node:buffer';
|
3
3
|
import { IncomingMessage } from 'node:http';
|
4
|
-
import { PassThrough, Readable } from 'node:stream';
|
4
|
+
import { addAbortSignal, PassThrough, Readable } from 'node:stream';
|
5
5
|
import busboy from 'busboy';
|
6
6
|
import { handleMaybePromise } from '@whatwg-node/promise-helpers';
|
7
7
|
import { hasArrayBufferMethod, hasBufferMethod, hasBytesMethod, PonyfillBlob } from './Blob.js';
|
@@ -25,9 +25,11 @@ export class PonyfillBody {
|
|
25
25
|
bodyUsed = false;
|
26
26
|
contentType = null;
|
27
27
|
contentLength = null;
|
28
|
+
signal = null;
|
28
29
|
constructor(bodyInit, options = {}) {
|
29
30
|
this.bodyInit = bodyInit;
|
30
31
|
this.options = options;
|
32
|
+
this.signal = options.signal || null;
|
31
33
|
const { bodyFactory, contentType, contentLength, bodyType, buffer } = processBodyInit(bodyInit, options?.signal);
|
32
34
|
this._bodyFactory = bodyFactory;
|
33
35
|
this.contentType = contentType;
|
@@ -48,6 +50,9 @@ export class PonyfillBody {
|
|
48
50
|
}
|
49
51
|
const body = this._bodyFactory();
|
50
52
|
this._generatedBody = body;
|
53
|
+
if (body?.readable && this.signal) {
|
54
|
+
addAbortSignal(this.signal, body.readable);
|
55
|
+
}
|
51
56
|
return body;
|
52
57
|
}
|
53
58
|
handleContentLengthHeader(forceSet = false) {
|
package/esm/Request.js
CHANGED
@@ -38,7 +38,7 @@ export class PonyfillRequest extends PonyfillBody {
|
|
38
38
|
bodyInit = options.body || null;
|
39
39
|
requestInit = options;
|
40
40
|
}
|
41
|
-
super(bodyInit,
|
41
|
+
super(bodyInit, requestInit);
|
42
42
|
this._url = _url;
|
43
43
|
this._parsedUrl = _parsedUrl;
|
44
44
|
this.cache = requestInit?.cache || 'default';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@whatwg-node/node-fetch",
|
3
|
-
"version": "0.7.15-alpha-
|
3
|
+
"version": "0.7.15-alpha-20250324192010-b283f7e2f0fd92fdb6ab59d74fe78de9fa4dbd78",
|
4
4
|
"description": "Fetch API implementation for Node",
|
5
5
|
"sideEffects": false,
|
6
6
|
"dependencies": {
|
package/typings/Body.d.cts
CHANGED
@@ -24,6 +24,7 @@ export declare class PonyfillBody<TJSON = any> implements Body {
|
|
24
24
|
bodyUsed: boolean;
|
25
25
|
contentType: string | null;
|
26
26
|
contentLength: number | null;
|
27
|
+
signal?: AbortSignal | null;
|
27
28
|
constructor(bodyInit: BodyPonyfillInit | null, options?: PonyfillBodyOptions);
|
28
29
|
private bodyType?;
|
29
30
|
private _bodyFactory;
|
package/typings/Body.d.ts
CHANGED
@@ -24,6 +24,7 @@ export declare class PonyfillBody<TJSON = any> implements Body {
|
|
24
24
|
bodyUsed: boolean;
|
25
25
|
contentType: string | null;
|
26
26
|
contentLength: number | null;
|
27
|
+
signal?: AbortSignal | null;
|
27
28
|
constructor(bodyInit: BodyPonyfillInit | null, options?: PonyfillBodyOptions);
|
28
29
|
private bodyType?;
|
29
30
|
private _bodyFactory;
|