From 63e8660f6c1a978743b0dc07c4c457a62bc6d6b7 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Wed, 21 Aug 2019 12:55:19 +0200 Subject: [PATCH] fix(core): update --- ts/smartrequest.request.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ts/smartrequest.request.ts b/ts/smartrequest.request.ts index e4676c1..c500176 100644 --- a/ts/smartrequest.request.ts +++ b/ts/smartrequest.request.ts @@ -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 ( domainArg: string, optionsArg: interfaces.ISmartRequestOptions = {}, @@ -64,6 +74,7 @@ export let request = async ( // merge options const defaultOptions: interfaces.ISmartRequestOptions = { + // agent: agent, autoJsonParse: true }; @@ -93,8 +104,10 @@ export let request = async ( // lets determine the request module to use const requestModule = (() => { if (parsedUrl.protocol === 'https:') { + optionsArg.agent = httpsAgent; return plugins.https; } else if (parsedUrl.protocol === 'http:') { + optionsArg.agent = httpAgent; return plugins.http; } else { throw new Error(`unsupported protocol: ${parsedUrl.protocol}`);