Merge pull request #4969 from lohxt1/send_request_default_options

add explicit HTTP agents with keepAlive to `bru.sendRequest` axios request config
This commit is contained in:
lohit
2025-06-24 19:53:58 +05:30
committed by GitHub

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');