Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@whatwg-node/node-fetch

Package Overview
Dependencies
Maintainers
1
Versions
620
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@whatwg-node/node-fetch - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2-alpha-20230202080931-398001d

30

index.js

@@ -703,3 +703,8 @@ 'use strict';

this.integrity = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.integrity) || '';
this.keepalive = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.keepalive) || true;
let defaultKeepAlive = true;
const connectionInHeaders = this.headers.get('connection');
if (connectionInHeaders) {
defaultKeepAlive = connectionInHeaders.toLowerCase() === 'keep-alive';
}
this.keepalive = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.keepalive) != null ? requestInit.keepalive : defaultKeepAlive;
this.method = ((_a = requestInit === null || requestInit === void 0 ? void 0 : requestInit.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'GET';

@@ -712,6 +717,4 @@ this.mode = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.mode) || 'cors';

this.url = url || '';
if (this.keepalive) {
if (!this.headers.has('connection')) {
this.headers.set('connection', 'keep-alive');
}
if (this.keepalive && !connectionInHeaders) {
this.headers.set('connection', 'keep-alive');
}

@@ -819,2 +822,11 @@ const contentTypeInHeaders = this.headers.get('content-type');

}
const AGENT_MAP = {
'http:keepAlive': new http.Agent({ keepAlive: true }),
'http:nonKeepAlive': new http.Agent({ keepAlive: false }),
'https:keepAlive': new https.Agent({ keepAlive: true }),
'https:nonKeepAlive': new https.Agent({ keepAlive: false }),
};
function getAgent(protocol, keepAlive) {
return AGENT_MAP[`${protocol}${keepAlive ? 'keepAlive' : 'nonKeepAlive'}`];
}
const BASE64_SUFFIX = ';base64';

@@ -874,7 +886,11 @@ function fetchPonyfill(info, init) {

fetchRequest.signal.addEventListener('abort', abortListener);
const nodeRequest = requestFn(url, {
const agent = getAgent(url.protocol, fetchRequest.keepalive);
const requestOptions = {
// signal: fetchRequest.signal will be added when v14 reaches EOL
method: fetchRequest.method,
headers: nodeHeaders,
});
rejectUnauthorized: false,
agent,
};
const nodeRequest = requestFn(url, requestOptions);
nodeRequest.once('response', nodeResponse => {

@@ -881,0 +897,0 @@ if (nodeResponse.headers.location) {

{
"name": "@whatwg-node/node-fetch",
"version": "0.0.1",
"version": "0.0.2-alpha-20230202080931-398001d",
"description": "Fetch API implementation for Node",

@@ -5,0 +5,0 @@ "sideEffects": false,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc