fix(core): update

This commit is contained in:
Philipp Kunz 2019-08-21 12:55:19 +02:00
parent 2358b1d48f
commit 63e8660f6c

View File

@ -55,6 +55,16 @@ const parseSocketPathAndRoute = (stringToParseArg: string) => {
}; };
}; };
const httpAgent = new plugins.http.Agent({
keepAlive: true,
keepAliveMsecs: 600000
});
const httpsAgent = new plugins.https.Agent({
keepAlive: true,
keepAliveMsecs: 600000
});
export let request = async ( export let request = async (
domainArg: string, domainArg: string,
optionsArg: interfaces.ISmartRequestOptions = {}, optionsArg: interfaces.ISmartRequestOptions = {},
@ -64,6 +74,7 @@ export let request = async (
// merge options // merge options
const defaultOptions: interfaces.ISmartRequestOptions = { const defaultOptions: interfaces.ISmartRequestOptions = {
// agent: agent,
autoJsonParse: true autoJsonParse: true
}; };
@ -93,8 +104,10 @@ export let request = async (
// lets determine the request module to use // lets determine the request module to use
const requestModule = (() => { const requestModule = (() => {
if (parsedUrl.protocol === 'https:') { if (parsedUrl.protocol === 'https:') {
optionsArg.agent = httpsAgent;
return plugins.https; return plugins.https;
} else if (parsedUrl.protocol === 'http:') { } else if (parsedUrl.protocol === 'http:') {
optionsArg.agent = httpAgent;
return plugins.http; return plugins.http;
} else { } else {
throw new Error(`unsupported protocol: ${parsedUrl.protocol}`); throw new Error(`unsupported protocol: ${parsedUrl.protocol}`);