Move content-length calculation to http module

- consolidate http / https functionality to single function
This commit is contained in:
Jason Fischer 2022-11-24 12:26:22 -08:00
parent ccfafe1b31
commit 9f03d18e49
No known key found for this signature in database
2 changed files with 14 additions and 30 deletions

View file

@ -20,7 +20,6 @@ export async function sendJsonRpcRequest(url, method, params, username, password
const client = new JSONRPCClient(async (rpcRequest) => {
const body = JSON.stringify(rpcRequest);
headers['content-length'] = Buffer.byteLength(body);
const httpRequestParams = {
method: "POST",
headers,
@ -49,7 +48,7 @@ export async function sendJsonRpcRequest(url, method, params, username, password
}
catch (e) {
if (e instanceof JSONRPCErrorException) {
logger.warn("Error calling JSONPRC endpoint: %s. %s", url, e.message);
logger.debug("Error calling JSONPRC endpoint: %s. %s", url, e.message);
return [200, "application/json", JSON.stringify({result: null, error: {code: e.code, message: e.message}})];
}