@whatwg-node/node-fetch 0.0.2-alpha-20230202081906-5436414 → 0.0.2-alpha-20230202120635-b6521c4
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/index.js +3 -24
- package/index.mjs +5 -26
- package/package.json +1 -1
package/index.js
CHANGED
@@ -700,12 +700,7 @@ class PonyfillRequest extends PonyfillBody {
|
|
700
700
|
this.credentials = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.credentials) || 'same-origin';
|
701
701
|
this.headers = new PonyfillHeaders(requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers);
|
702
702
|
this.integrity = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.integrity) || '';
|
703
|
-
|
704
|
-
const connectionInHeaders = this.headers.get('connection');
|
705
|
-
if (connectionInHeaders) {
|
706
|
-
defaultKeepAlive = connectionInHeaders.toLowerCase() === 'keep-alive';
|
707
|
-
}
|
708
|
-
this.keepalive = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.keepalive) != null ? requestInit.keepalive : defaultKeepAlive;
|
703
|
+
this.keepalive = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.keepalive) != null ? requestInit === null || requestInit === void 0 ? void 0 : requestInit.keepalive : false;
|
709
704
|
this.method = ((_a = requestInit === null || requestInit === void 0 ? void 0 : requestInit.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'GET';
|
710
705
|
this.mode = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.mode) || 'cors';
|
711
706
|
this.redirect = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.redirect) || 'follow';
|
@@ -713,9 +708,6 @@ class PonyfillRequest extends PonyfillBody {
|
|
713
708
|
this.referrerPolicy = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrerPolicy) || 'no-referrer';
|
714
709
|
this.signal = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.signal) || new PonyfillAbortController().signal;
|
715
710
|
this.url = url || '';
|
716
|
-
if (this.keepalive && !connectionInHeaders) {
|
717
|
-
this.headers.set('connection', 'keep-alive');
|
718
|
-
}
|
719
711
|
const contentTypeInHeaders = this.headers.get('content-type');
|
720
712
|
if (!contentTypeInHeaders) {
|
721
713
|
if (this.contentType) {
|
@@ -817,15 +809,6 @@ function getRequestFnForProtocol(protocol) {
|
|
817
809
|
}
|
818
810
|
throw new Error(`Unsupported protocol: ${protocol}`);
|
819
811
|
}
|
820
|
-
const AGENT_MAP = {
|
821
|
-
'http:keepAlive': new http.Agent({ keepAlive: true }),
|
822
|
-
'http:nonKeepAlive': new http.Agent({ keepAlive: false }),
|
823
|
-
'https:keepAlive': new https.Agent({ keepAlive: true }),
|
824
|
-
'https:nonKeepAlive': new https.Agent({ keepAlive: false }),
|
825
|
-
};
|
826
|
-
function getAgent(protocol, keepAlive) {
|
827
|
-
return AGENT_MAP[`${protocol}${keepAlive ? 'keepAlive' : 'nonKeepAlive'}`];
|
828
|
-
}
|
829
812
|
const BASE64_SUFFIX = ';base64';
|
830
813
|
function fetchPonyfill(info, init) {
|
831
814
|
if (typeof info === 'string' || info instanceof URL) {
|
@@ -880,15 +863,11 @@ function fetchPonyfill(info, init) {
|
|
880
863
|
reject(new PonyfillAbortError(reason));
|
881
864
|
};
|
882
865
|
fetchRequest.signal.addEventListener('abort', abortListener);
|
883
|
-
const
|
884
|
-
const requestOptions = {
|
866
|
+
const nodeRequest = requestFn(url, {
|
885
867
|
// signal: fetchRequest.signal will be added when v14 reaches EOL
|
886
868
|
method: fetchRequest.method,
|
887
869
|
headers: nodeHeaders,
|
888
|
-
|
889
|
-
agent,
|
890
|
-
};
|
891
|
-
const nodeRequest = requestFn(url, requestOptions);
|
870
|
+
});
|
892
871
|
nodeRequest.once('response', nodeResponse => {
|
893
872
|
if (nodeResponse.headers.location) {
|
894
873
|
if (fetchRequest.redirect === 'error') {
|
package/index.mjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { createReadStream } from 'fs';
|
2
|
-
import {
|
3
|
-
import {
|
2
|
+
import { request as request$1 } from 'http';
|
3
|
+
import { request } from 'https';
|
4
4
|
import { Readable } from 'stream';
|
5
5
|
import { fileURLToPath } from 'url';
|
6
6
|
import { EventTarget, CustomEvent } from '@whatwg-node/events';
|
@@ -694,12 +694,7 @@ class PonyfillRequest extends PonyfillBody {
|
|
694
694
|
this.credentials = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.credentials) || 'same-origin';
|
695
695
|
this.headers = new PonyfillHeaders(requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers);
|
696
696
|
this.integrity = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.integrity) || '';
|
697
|
-
|
698
|
-
const connectionInHeaders = this.headers.get('connection');
|
699
|
-
if (connectionInHeaders) {
|
700
|
-
defaultKeepAlive = connectionInHeaders.toLowerCase() === 'keep-alive';
|
701
|
-
}
|
702
|
-
this.keepalive = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.keepalive) != null ? requestInit.keepalive : defaultKeepAlive;
|
697
|
+
this.keepalive = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.keepalive) != null ? requestInit === null || requestInit === void 0 ? void 0 : requestInit.keepalive : false;
|
703
698
|
this.method = ((_a = requestInit === null || requestInit === void 0 ? void 0 : requestInit.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'GET';
|
704
699
|
this.mode = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.mode) || 'cors';
|
705
700
|
this.redirect = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.redirect) || 'follow';
|
@@ -707,9 +702,6 @@ class PonyfillRequest extends PonyfillBody {
|
|
707
702
|
this.referrerPolicy = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrerPolicy) || 'no-referrer';
|
708
703
|
this.signal = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.signal) || new PonyfillAbortController().signal;
|
709
704
|
this.url = url || '';
|
710
|
-
if (this.keepalive && !connectionInHeaders) {
|
711
|
-
this.headers.set('connection', 'keep-alive');
|
712
|
-
}
|
713
705
|
const contentTypeInHeaders = this.headers.get('content-type');
|
714
706
|
if (!contentTypeInHeaders) {
|
715
707
|
if (this.contentType) {
|
@@ -811,15 +803,6 @@ function getRequestFnForProtocol(protocol) {
|
|
811
803
|
}
|
812
804
|
throw new Error(`Unsupported protocol: ${protocol}`);
|
813
805
|
}
|
814
|
-
const AGENT_MAP = {
|
815
|
-
'http:keepAlive': new Agent({ keepAlive: true }),
|
816
|
-
'http:nonKeepAlive': new Agent({ keepAlive: false }),
|
817
|
-
'https:keepAlive': new Agent$1({ keepAlive: true }),
|
818
|
-
'https:nonKeepAlive': new Agent$1({ keepAlive: false }),
|
819
|
-
};
|
820
|
-
function getAgent(protocol, keepAlive) {
|
821
|
-
return AGENT_MAP[`${protocol}${keepAlive ? 'keepAlive' : 'nonKeepAlive'}`];
|
822
|
-
}
|
823
806
|
const BASE64_SUFFIX = ';base64';
|
824
807
|
function fetchPonyfill(info, init) {
|
825
808
|
if (typeof info === 'string' || info instanceof URL) {
|
@@ -874,15 +857,11 @@ function fetchPonyfill(info, init) {
|
|
874
857
|
reject(new PonyfillAbortError(reason));
|
875
858
|
};
|
876
859
|
fetchRequest.signal.addEventListener('abort', abortListener);
|
877
|
-
const
|
878
|
-
const requestOptions = {
|
860
|
+
const nodeRequest = requestFn(url, {
|
879
861
|
// signal: fetchRequest.signal will be added when v14 reaches EOL
|
880
862
|
method: fetchRequest.method,
|
881
863
|
headers: nodeHeaders,
|
882
|
-
|
883
|
-
agent,
|
884
|
-
};
|
885
|
-
const nodeRequest = requestFn(url, requestOptions);
|
864
|
+
});
|
886
865
|
nodeRequest.once('response', nodeResponse => {
|
887
866
|
if (nodeResponse.headers.location) {
|
888
867
|
if (fetchRequest.redirect === 'error') {
|
package/package.json
CHANGED