1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Clean up console.logs

This commit is contained in:
Ben Hardill 2021-05-11 09:56:22 +01:00
parent f6a3671366
commit 4c8e895ac7
No known key found for this signature in database
GPG Key ID: 74DD076979ABB1E7

View File

@ -65,6 +65,7 @@ module.exports = function(RED) {
} }
this.on("input",function(msg,nodeSend,nodeDone) { this.on("input",function(msg,nodeSend,nodeDone) {
//reset redirectList on each request
redirectList = []; redirectList = [];
var preRequestTimestamp = process.hrtime(); var preRequestTimestamp = process.hrtime();
node.status({fill:"blue",shape:"dot",text:"httpin.status.requesting"}); node.status({fill:"blue",shape:"dot",text:"httpin.status.requesting"});
@ -107,10 +108,11 @@ module.exports = function(RED) {
method = msg.method.toUpperCase(); // use the msg parameter method = msg.method.toUpperCase(); // use the msg parameter
} }
var isHttps = (/^https/i.test(url)); // var isHttps = (/^https/i.test(url));
var opts = {}; var opts = {};
// set defaultport, else when using HttpsProxyAgent, it's defaultPort of 443 will be used :(. // set defaultport, else when using HttpsProxyAgent, it's defaultPort of 443 will be used :(.
// Had to remove this to get http->https redirect to work
// opts.defaultPort = isHttps?443:80; // opts.defaultPort = isHttps?443:80;
opts.timeout = node.reqTimeout; opts.timeout = node.reqTimeout;
opts.method = method; opts.method = method;
@ -341,6 +343,7 @@ module.exports = function(RED) {
if (match) { if (match) {
let proxyAgent; let proxyAgent;
let proxyURL = new URL(prox); let proxyURL = new URL(prox);
//set username/password to null to stop empty creds header
let proxyOptions = { let proxyOptions = {
proxy: { proxy: {
protocol: proxyURL.protocol, protocol: proxyURL.protocol,
@ -351,24 +354,22 @@ module.exports = function(RED) {
}, },
maxFreeSockets: 256, maxFreeSockets: 256,
maxSockets: 256, maxSockets: 256,
keepAlive: false keepAlive: true
} }
if (proxyConfig && proxyConfig.credentials) { if (proxyConfig && proxyConfig.credentials) {
// console.log("proxyConfig.creds", proxyConfig.credentials)
let proxyUsername = proxyConfig.credentials.username || ''; let proxyUsername = proxyConfig.credentials.username || '';
let proxyPassword = proxyConfig.credentials.password || ''; let proxyPassword = proxyConfig.credentials.password || '';
if (proxyUsername || proxyPassword) { if (proxyUsername || proxyPassword) {
proxyOptions.proxy.username = proxyUsername; proxyOptions.proxy.username = proxyUsername;
proxyOptions.password = proxyPassword; proxyOptions.proxy.password = proxyPassword;
} }
} }
opts.agent = {}; //need both incase of http -> https redirec
// if (/^http:/.test(url)) { opts.agent = {
opts.agent.http = new HttpProxyAgent(proxyOptions) http: new HttpProxyAgent(proxyOptions),
// } else { https: new HttpsProxyAgent(proxyOptions)
opts.agent.https = new HttpsProxyAgent(proxyOptions) };
// }
// console.log("ProxyOptions:",proxyOptions);
} else { } else {
node.warn("Bad proxy url: "+ prox); node.warn("Bad proxy url: "+ prox);
} }