From 3a4756bd8328b06dcd0ec74c6b6c16eb138ef911 Mon Sep 17 00:00:00 2001 From: dceejay Date: Sat, 23 May 2015 18:55:11 +0100 Subject: [PATCH] let urllib parse proxy url more cleanly in http-request node. --- nodes/core/io/21-httpin.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/nodes/core/io/21-httpin.js b/nodes/core/io/21-httpin.js index e25298bd1..3d9d6b5c8 100644 --- a/nodes/core/io/21-httpin.js +++ b/nodes/core/io/21-httpin.js @@ -271,14 +271,18 @@ module.exports = function(RED) { } if (prox && !noproxy) { var match = prox.match(/^(http:\/\/)?(.+)?:([0-9]+)?/i); - console.log("MATCH",match); if (match) { - opts.protocol = "http:"; + //opts.protocol = "http:"; + //opts.host = opts.hostname = match[2]; + //opts.port = (match[3] != null ? match[3] : 80); opts.headers['Host'] = opts.host; - opts.host = opts.hostname = match[2], - opts.port = (match[3] != null ? match[3] : 80), - opts.path = opts.pathname = opts.href; - urltotest = match[2]; + var heads = opts.headers; + var path = opts.pathname = opts.href; + opts = urllib.parse(prox); + opts.path = opts.pathname = path; + opts.headers = heads; + //console.log(opts); + urltotest = match[0]; } else { node.warn("Bad proxy url: "+process.env.http_proxy); } }