Fix HTTPS signing for POSTS

This commit is contained in:
Bryan Ashby 2023-08-24 12:11:23 -06:00
parent 2964c01841
commit 0035ef4f39
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
1 changed files with 9 additions and 1 deletions

View File

@ -2,7 +2,8 @@ const { Errors } = require('./enig_error.js');
// deps // deps
const { isString, isObject, truncate } = require('lodash'); const { isString, isObject, truncate } = require('lodash');
const { https } = require('follow-redirects'); const httpsNoRedirects = require('node:https');
const { https: httpsWithRedirects } = require('follow-redirects');
const httpSignature = require('http-signature'); const httpSignature = require('http-signature');
const crypto = require('crypto'); const crypto = require('crypto');
@ -78,6 +79,13 @@ function _makeRequest(url, options, cb) {
} }
}; };
let https;
if (options.method === 'POST' || options.sign) {
https = httpsNoRedirects;
} else {
https = httpsWithRedirects;
}
const req = https.request(url, options, res => { const req = https.request(url, options, res => {
let body = []; let body = [];
res.on('data', d => { res.on('data', d => {