the-forest/client/node_modules/@libsql/isomorphic-fetch/node.js
2024-09-17 20:35:18 -04:00

21 lines
585 B
JavaScript

import http from 'http';
import https from 'https';
const _Request = Request;
const _Headers = Headers;
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 });
}
export { fetchWithAgentSelection as fetch, _Request as Request, _Headers as Headers};