@whatwg-node/node-fetch 0.4.8-alpha-20230714133255-ab42aad → 0.4.8-alpha-20230714142154-b870e90
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 +9 -6
- package/cjs/fetchNodeHttp.js +2 -2
- package/esm/fetchCurl.js +9 -6
- package/esm/fetchNodeHttp.js +2 -2
- package/package.json +1 -1
package/cjs/fetchCurl.js
CHANGED
@@ -19,6 +19,7 @@ async function fetchCurl(fetchRequest) {
|
|
19
19
|
});
|
20
20
|
let easyNativeBinding;
|
21
21
|
const curlyOptions = {
|
22
|
+
sslVerifyPeer: false,
|
22
23
|
// we want the unparsed binary response to be returned as a stream to us
|
23
24
|
curlyStreamResponse: true,
|
24
25
|
curlyResponseBodyParser: false,
|
@@ -26,7 +27,7 @@ async function fetchCurl(fetchRequest) {
|
|
26
27
|
if (easyNativeBinding == null) {
|
27
28
|
easyNativeBinding = this;
|
28
29
|
}
|
29
|
-
return fetchRequest
|
30
|
+
return fetchRequest['_signal']?.aborted ? 1 : 0;
|
30
31
|
},
|
31
32
|
upload: nodeReadable != null,
|
32
33
|
transferEncoding: false,
|
@@ -45,11 +46,13 @@ async function fetchCurl(fetchRequest) {
|
|
45
46
|
curlyOptions.inFileSize = size;
|
46
47
|
}
|
47
48
|
const { curly, CurlCode, CurlPause } = globalThis['libcurl'];
|
48
|
-
|
49
|
-
|
50
|
-
easyNativeBinding
|
51
|
-
|
52
|
-
|
49
|
+
if (fetchRequest['_signal']) {
|
50
|
+
fetchRequest['_signal'].onabort = () => {
|
51
|
+
if (easyNativeBinding != null) {
|
52
|
+
easyNativeBinding.pause(CurlPause.Recv);
|
53
|
+
}
|
54
|
+
};
|
55
|
+
}
|
53
56
|
const curlyResult = await curly(fetchRequest.url, curlyOptions);
|
54
57
|
const responseHeaders = new Headers_js_1.PonyfillHeaders();
|
55
58
|
curlyResult.headers.forEach(headerInfo => {
|
package/cjs/fetchNodeHttp.js
CHANGED
@@ -33,11 +33,11 @@ function fetchNodeHttp(fetchRequest) {
|
|
33
33
|
const nodeRequest = requestFn(fetchRequest.url, {
|
34
34
|
method: fetchRequest.method,
|
35
35
|
headers: nodeHeaders,
|
36
|
-
signal: fetchRequest
|
36
|
+
signal: fetchRequest['_signal'] ?? undefined,
|
37
37
|
agent: fetchRequest.agent,
|
38
38
|
});
|
39
39
|
// TODO: will be removed after v16 reaches EOL
|
40
|
-
fetchRequest
|
40
|
+
fetchRequest['_signal']?.addEventListener('abort', () => {
|
41
41
|
if (!nodeRequest.aborted) {
|
42
42
|
nodeRequest.abort();
|
43
43
|
}
|
package/esm/fetchCurl.js
CHANGED
@@ -16,6 +16,7 @@ export async function fetchCurl(fetchRequest) {
|
|
16
16
|
});
|
17
17
|
let easyNativeBinding;
|
18
18
|
const curlyOptions = {
|
19
|
+
sslVerifyPeer: false,
|
19
20
|
// we want the unparsed binary response to be returned as a stream to us
|
20
21
|
curlyStreamResponse: true,
|
21
22
|
curlyResponseBodyParser: false,
|
@@ -23,7 +24,7 @@ export async function fetchCurl(fetchRequest) {
|
|
23
24
|
if (easyNativeBinding == null) {
|
24
25
|
easyNativeBinding = this;
|
25
26
|
}
|
26
|
-
return fetchRequest
|
27
|
+
return fetchRequest['_signal']?.aborted ? 1 : 0;
|
27
28
|
},
|
28
29
|
upload: nodeReadable != null,
|
29
30
|
transferEncoding: false,
|
@@ -42,11 +43,13 @@ export async function fetchCurl(fetchRequest) {
|
|
42
43
|
curlyOptions.inFileSize = size;
|
43
44
|
}
|
44
45
|
const { curly, CurlCode, CurlPause } = globalThis['libcurl'];
|
45
|
-
|
46
|
-
|
47
|
-
easyNativeBinding
|
48
|
-
|
49
|
-
|
46
|
+
if (fetchRequest['_signal']) {
|
47
|
+
fetchRequest['_signal'].onabort = () => {
|
48
|
+
if (easyNativeBinding != null) {
|
49
|
+
easyNativeBinding.pause(CurlPause.Recv);
|
50
|
+
}
|
51
|
+
};
|
52
|
+
}
|
50
53
|
const curlyResult = await curly(fetchRequest.url, curlyOptions);
|
51
54
|
const responseHeaders = new PonyfillHeaders();
|
52
55
|
curlyResult.headers.forEach(headerInfo => {
|
package/esm/fetchNodeHttp.js
CHANGED
@@ -30,11 +30,11 @@ export function fetchNodeHttp(fetchRequest) {
|
|
30
30
|
const nodeRequest = requestFn(fetchRequest.url, {
|
31
31
|
method: fetchRequest.method,
|
32
32
|
headers: nodeHeaders,
|
33
|
-
signal: fetchRequest
|
33
|
+
signal: fetchRequest['_signal'] ?? undefined,
|
34
34
|
agent: fetchRequest.agent,
|
35
35
|
});
|
36
36
|
// TODO: will be removed after v16 reaches EOL
|
37
|
-
fetchRequest
|
37
|
+
fetchRequest['_signal']?.addEventListener('abort', () => {
|
38
38
|
if (!nodeRequest.aborted) {
|
39
39
|
nodeRequest.abort();
|
40
40
|
}
|