Compare commits

...

6 Commits

Author SHA1 Message Date
376225888c 1.1.20 2019-08-21 12:55:20 +02:00
63e8660f6c fix(core): update 2019-08-21 12:55:19 +02:00
2358b1d48f 1.1.19 2019-08-16 22:00:01 +02:00
9db29bacc2 fix(core): update 2019-08-16 22:00:01 +02:00
5f27b6834c 1.1.18 2019-08-16 21:43:10 +02:00
6717ecf80c fix(core): update 2019-08-16 21:43:09 +02:00
4 changed files with 18 additions and 3 deletions

View File

@ -48,7 +48,7 @@ testLTS:
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
- priv
testBuild:
stage: test

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartrequest",
"version": "1.1.17",
"version": "1.1.20",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartrequest",
"version": "1.1.17",
"version": "1.1.20",
"private": false,
"description": "dropin replacement for request",
"main": "dist/index.js",

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 (
domainArg: string,
optionsArg: interfaces.ISmartRequestOptions = {},
@ -64,6 +74,7 @@ export let request = async (
// merge options
const defaultOptions: interfaces.ISmartRequestOptions = {
// agent: agent,
autoJsonParse: true
};
@ -88,11 +99,15 @@ export let request = async (
optionsArg.path = detailedUnixPath.path;
}
// TODO: support tcp sockets
// 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}`);