From 5e3cbadffcdcbc32ed81bfc4a1fe8a206a3e9671 Mon Sep 17 00:00:00 2001 From: Steve-Mcl Date: Sun, 17 Mar 2024 12:51:57 +0000 Subject: [PATCH] merge dev --- .../nodes/core/network/21-httprequest.js | 39 ++++++------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js index 4e3e46d0a..dab48d5c1 100644 --- a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js +++ b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js @@ -16,12 +16,8 @@ module.exports = async function(RED) { "use strict"; -<<<<<<< HEAD const { getProxyForUrl, parseUrl } = require('./lib/proxyHelper'); - const got = require("got"); -======= const { got } = await import('got') ->>>>>>> upstream/dev const {CookieJar} = require("tough-cookie"); const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent'); const FormData = require('form-data'); @@ -104,7 +100,6 @@ in your Node-RED user directory (${RED.settings.userDir}). if (n.paytoqs === true || n.paytoqs === "query") { paytoqs = true; } else if (n.paytoqs === "body") { paytobody = true; } -<<<<<<< HEAD let proxyConfig = n.proxy ? RED.nodes.getNode(n.proxy) || {} : null const getProxy = (url) => { const proxyOptions = Object.assign({}, RED.settings.proxyOptions); @@ -115,21 +110,6 @@ in your Node-RED user directory (${RED.settings.userDir}). } } return getProxyForUrl(url, proxyOptions) -======= - node.insecureHTTPParser = n.insecureHTTPParser - - var prox, noprox; - if (process.env.http_proxy) { prox = process.env.http_proxy; } - if (process.env.HTTP_PROXY) { prox = process.env.HTTP_PROXY; } - if (process.env.no_proxy) { noprox = process.env.no_proxy.split(","); } - if (process.env.NO_PROXY) { noprox = process.env.NO_PROXY.split(","); } - - var proxyConfig = null; - if (n.proxy) { - proxyConfig = RED.nodes.getNode(n.proxy); - prox = proxyConfig.url; - noprox = proxyConfig.noproxy; ->>>>>>> upstream/dev } let prox = getProxy(nodeUrl || '') @@ -160,7 +140,15 @@ in your Node-RED user directory (${RED.settings.userDir}). }); } } - + /** + * @param {Object} headersObject + * @param {string} name + * @return {any} value + */ + const getHeaderValue = (headersObject, name) => { + const asLowercase = name.toLowercase(); + return headersObject[Object.keys(headersObject).find(k => k.toLowerCase() === asLowercase)]; + } this.on("input",function(msg,nodeSend,nodeDone) { checkNodeAgentPatch(); //reset redirectList on each request @@ -561,8 +549,8 @@ in your Node-RED user directory (${RED.settings.userDir}). keepAlive: true } if (proxyConfig && proxyConfig.credentials) { - let proxyUsername = proxyConfig.credentials.username || ''; - let proxyPassword = proxyConfig.credentials.password || ''; + const proxyUsername = proxyConfig.credentials.username || ''; + const proxyPassword = proxyConfig.credentials.password || ''; if (proxyUsername || proxyPassword) { proxyOptions.proxy = proxyURL proxyOptions.proxy.username = proxyUsername; @@ -576,14 +564,9 @@ in your Node-RED user directory (${RED.settings.userDir}). //need both incase of http -> https redirect opts.agent = { http: new HttpProxyAgent(proxyOptions), -<<<<<<< HEAD https: new HttpProxyAgent(proxyOptions) }; -======= - https: new HttpsProxyAgent(proxyOptions) - } ->>>>>>> upstream/dev } else { node.warn("Bad proxy url: " + proxyUrl); }