From 7c24c7465aab6f3c28b88d7d6d84668c11e0384e Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 6 Feb 2014 22:14:27 +0000 Subject: [PATCH] HTTP Request: allow message to override https Fixes #147 --- nodes/core/io/21-httpin.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nodes/core/io/21-httpin.js b/nodes/core/io/21-httpin.js index 82e684ac8..54c2b6f28 100644 --- a/nodes/core/io/21-httpin.js +++ b/nodes/core/io/21-httpin.js @@ -82,18 +82,19 @@ RED.nodes.registerType("http response",HTTPOut); function HTTPRequest(n) { RED.nodes.createNode(this,n); - var url = n.url; + var nodeUrl = n.url; var method = n.method || "GET"; - var httplib = (/^https/.test(url))?https:http; var node = this; this.on("input",function(msg) { + + var url = msg.url||nodeUrl; - var opts = urllib.parse(msg.url||url); + var opts = urllib.parse(url); opts.method = (msg.method||method).toUpperCase(); if (msg.headers) { opts.headers = msg.headers; } - var req = httplib.request(opts,function(res) { + var req = ((/^https/.test(url))?https:http).request(opts,function(res) { res.setEncoding('utf8'); msg.statusCode = res.statusCode; msg.headers = res.headers;