the-forest/client/node_modules/@libsql/isomorphic-fetch/node.cjs

23 lines
625 B
JavaScript
Raw Normal View History

2024-09-17 20:35:18 -04:00
"use strict";
const _Request = Request;
const _Headers = Headers;
const http = require("node:http");
const https = require("node:https");
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
function agentSelector(parsedUrl) {
if (parsedUrl.protocol === 'https:') {
return httpsAgent;
} else {
return httpAgent;
}
}
function fetchWithAgentSelection(resource, options = {}) {
return fetch(resource, { agent: agentSelector, ...options });
}
module.exports = { fetch: fetchWithAgentSelection, Request: _Request, Headers: _Headers };