mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
add keepalive option in JsonApi.getResponse
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
2446b6cf9b
commit
9aa5b5d875
@ -21,6 +21,8 @@
|
||||
|
||||
// Base http-service / json-api class
|
||||
|
||||
import { Agent as HttpAgent } from "http";
|
||||
import { Agent as HttpsAgent } from "https";
|
||||
import { merge } from "lodash";
|
||||
import fetch, { Response, RequestInit } from "node-fetch";
|
||||
import { stringify } from "querystring";
|
||||
@ -95,6 +97,12 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
||||
reqInit.method = "get";
|
||||
}
|
||||
|
||||
if (!reqInit.agent) {
|
||||
const agentOpts = { keepAlive: true };
|
||||
|
||||
reqInit.agent = reqUrl.startsWith("https:") ? new HttpsAgent(agentOpts) : new HttpAgent(agentOpts);
|
||||
}
|
||||
|
||||
if (query) {
|
||||
const queryString = stringify(query);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user