diff --git a/nodes/core/io/21-httpin.js b/nodes/core/io/21-httpin.js index 84b459b38..ce6c4d112 100644 --- a/nodes/core/io/21-httpin.js +++ b/nodes/core/io/21-httpin.js @@ -77,13 +77,13 @@ module.exports = function(RED) { } var httpMiddleware = function(req,res,next) { next(); } - + if (RED.settings.httpNodeMiddleware) { if (typeof RED.settings.httpNodeMiddleware === "function") { httpMiddleware = RED.settings.httpNodeMiddleware; } } - + var metricsHandler = function(req,res,next) { next(); } if (this.metric()) { @@ -185,6 +185,13 @@ module.exports = function(RED) { var nodeMethod = n.method || "GET"; this.ret = n.ret || "txt"; var node = this; + + var prox, noprox; + if (process.env.http_proxy != null) { prox = process.env.http_proxy; } + if (process.env.HTTP_PROXY != null) { prox = process.env.HTTP_PROXY; } + if (process.env.no_proxy != null) { noprox = process.env.no_proxy.split(","); } + if (process.env.NO_PROXY != null) { noprox = process.env.NO_PROXY.split(","); } + this.on("input",function(msg) { var preRequestTimestamp = process.hrtime(); node.status({fill:"blue",shape:"dot",text:"requesting"}); @@ -256,8 +263,14 @@ module.exports = function(RED) { } } var urltotest = url; - if (process.env.http_proxy != null) { - var match = process.env.http_proxy.match(/^(http:\/\/)?([^:\/]+)(:([0-9]+))?/i); + var noproxy; + if (noprox) { + for (var i in noprox) { + if (url.indexOf(noprox[i]) !== -1) { noproxy=true; } + } + } + if (prox && !noproxy) { + var match = prox.match(/^(http:\/\/)?([^:\/]+)(:([0-9]+))?/i); if (match) { opts.protocol = "http:"; opts.headers['Host'] = opts.host;