This commit is contained in:
Benjamin Toby
2025-01-21 08:24:29 +01:00
parent 4aa69791c1
commit 9f773de1a1
3 changed files with 26 additions and 15 deletions
@@ -37,18 +37,23 @@ export default function httpRequest<
delete params.query;
delete params.urlEncodedFormBody;
let finalHeaders: http.OutgoingHttpHeaders = {
"Content-Type": isUrlEncodedFormBody
? "application/x-www-form-urlencoded"
: "application/json",
};
if (reqPayloadString) {
finalHeaders["Content-Length"] =
Buffer.from(reqPayloadString).length;
}
finalHeaders = { ...finalHeaders, ...params.headers };
/** @type {import("node:https").RequestOptions} */
const requestOptions: import("node:https").RequestOptions = {
...params,
headers: {
"Content-Type": isUrlEncodedFormBody
? "application/x-www-form-urlencoded"
: "application/json",
"Content-Length": reqPayloadString
? Buffer.from(reqPayloadString).length
: undefined,
...params.headers,
},
headers: finalHeaders,
port: paramScheme == "https" ? 443 : params.port,
path: finalPath,
};