fix(core): update
This commit is contained in:
parent
1f408b5123
commit
a73c78e54b
746
package-lock.json
generated
746
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -28,10 +28,10 @@
|
|||||||
"form-data": "^2.3.3"
|
"form-data": "^2.3.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.8",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tsrun": "^1.2.5",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@gitzone/tstest": "^1.0.20",
|
"@gitzone/tstest": "^1.0.24",
|
||||||
"@pushrocks/tapbundle": "^3.0.9",
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
"@types/node": "^11.13.6",
|
"@types/node": "^11.13.6",
|
||||||
"tslint": "^5.19.0",
|
"tslint": "^5.19.0",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
|
@ -2,6 +2,7 @@ import * as plugins from './smartrequest.plugins';
|
|||||||
import * as https from 'https';
|
import * as https from 'https';
|
||||||
|
|
||||||
export interface ISmartRequestOptions extends https.RequestOptions {
|
export interface ISmartRequestOptions extends https.RequestOptions {
|
||||||
|
keepAlive?: boolean;
|
||||||
requestBody?: any;
|
requestBody?: any;
|
||||||
autoJsonParse?: boolean;
|
autoJsonParse?: boolean;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,14 @@ const httpAgent = new plugins.http.Agent({
|
|||||||
keepAliveMsecs: 600000
|
keepAliveMsecs: 600000
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a custom http agent to make sure we can set custom keepAlive options for speedy subsequent calls
|
||||||
|
*/
|
||||||
|
const httpAgentKeepAliveFalse = new plugins.http.Agent({
|
||||||
|
keepAlive: false,
|
||||||
|
keepAliveMsecs: 600000
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a custom https agent to make sure we can set custom keepAlive options for speedy subsequent calls
|
* a custom https agent to make sure we can set custom keepAlive options for speedy subsequent calls
|
||||||
*/
|
*/
|
||||||
@ -70,6 +78,14 @@ const httpsAgent = new plugins.https.Agent({
|
|||||||
keepAliveMsecs: 600000
|
keepAliveMsecs: 600000
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a custom https agent to make sure we can set custom keepAlive options for speedy subsequent calls
|
||||||
|
*/
|
||||||
|
const httpsAgentKeepAliveFalse = new plugins.https.Agent({
|
||||||
|
keepAlive: false,
|
||||||
|
keepAliveMsecs: 600000
|
||||||
|
});
|
||||||
|
|
||||||
export let request = async (
|
export let request = async (
|
||||||
domainArg: string,
|
domainArg: string,
|
||||||
optionsArg: interfaces.ISmartRequestOptions = {},
|
optionsArg: interfaces.ISmartRequestOptions = {},
|
||||||
@ -80,7 +96,8 @@ export let request = async (
|
|||||||
// merge options
|
// merge options
|
||||||
const defaultOptions: interfaces.ISmartRequestOptions = {
|
const defaultOptions: interfaces.ISmartRequestOptions = {
|
||||||
// agent: agent,
|
// agent: agent,
|
||||||
autoJsonParse: true
|
autoJsonParse: true,
|
||||||
|
keepAlive:true,
|
||||||
};
|
};
|
||||||
|
|
||||||
optionsArg = {
|
optionsArg = {
|
||||||
@ -107,7 +124,21 @@ 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:') {
|
switch (true) {
|
||||||
|
case parsedUrl.protocol === 'https:' && optionsArg.keepAlive:
|
||||||
|
optionsArg.agent = httpsAgent;
|
||||||
|
return plugins.https;
|
||||||
|
case parsedUrl.protocol === 'https:' && !optionsArg.keepAlive:
|
||||||
|
optionsArg.agent = httpsAgentKeepAliveFalse;
|
||||||
|
return plugins.https;
|
||||||
|
case parsedUrl.protocol === 'http:' && optionsArg.keepAlive:
|
||||||
|
optionsArg.agent = httpAgent;
|
||||||
|
return plugins.http;
|
||||||
|
case parsedUrl.protocol === 'http:' && !optionsArg.keepAlive:
|
||||||
|
optionsArg.agent = httpAgentKeepAliveFalse;
|
||||||
|
return plugins.http;
|
||||||
|
}
|
||||||
|
if () {
|
||||||
optionsArg.agent = httpsAgent;
|
optionsArg.agent = httpsAgent;
|
||||||
return plugins.https;
|
return plugins.https;
|
||||||
} else if (parsedUrl.protocol === 'http:') {
|
} else if (parsedUrl.protocol === 'http:') {
|
||||||
|
Loading…
Reference in New Issue
Block a user