Add fix for HttpsProxyAgent using an incorrect default port for http:

This commit is contained in:
Simon Hailes 2019-11-03 11:08:24 +00:00
parent d32d04bd4e
commit aa86cfc55f
1 changed files with 6 additions and 0 deletions

View File

@ -88,8 +88,13 @@ module.exports = function(RED) {
if (msg.method && n.method && (n.method === "use")) {
method = msg.method.toUpperCase(); // use the msg parameter
}
var isHttps = (/^https/.test(url));
var opts = {};
opts.url = url;
// set defaultport, else when using HttpsProxyAgent, it's defaultPort of 443 will be used :(.
opts.defaultPort = isHttps?443:80;
opts.timeout = node.reqTimeout;
opts.method = method;
opts.headers = {};
@ -284,6 +289,7 @@ module.exports = function(RED) {
opts.headers[clSet] = opts.headers['content-length'];
delete opts.headers['content-length'];
}
var noproxy;
if (noprox) {
for (var i in noprox) {