add explicit HTTP agents with keepAlive to bru.sendRequest axios instance

This commit is contained in:
lohit
2025-06-24 17:12:17 +05:30
parent 2bbfb28090
commit 879c124aec

View File

@@ -1,4 +1,6 @@
import { default as axios, AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
import http from 'node:http';
import https from 'node:https';
/**
*
@@ -25,6 +27,8 @@ type ModifiedAxiosResponse = AxiosResponse & {
}
const baseRequestConfig: Partial<AxiosRequestConfig> = {
httpAgent: new http.Agent({ keepAlive: true }),
httpsAgent: new https.Agent({ keepAlive: true }),
transformRequest: function transformRequest(data: any, headers: AxiosRequestHeaders) {
const contentType = headers.getContentType() || '';
const hasJSONContentType = contentType.includes('json');