From 3b60e1a0e399b2647331a8ec5676ac20c3df8dc1 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Tue, 22 Oct 2013 20:25:14 +0100 Subject: [PATCH 1/3] Added error trap to xml2js node. --- nodes/analysis/73-parsexml.html | 58 ++++++++++++++++----------------- nodes/analysis/73-parsexml.js | 37 +++++++++++---------- 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/nodes/analysis/73-parsexml.html b/nodes/analysis/73-parsexml.html index 71b3a21cb..cf51ef2db 100644 --- a/nodes/analysis/73-parsexml.html +++ b/nodes/analysis/73-parsexml.html @@ -15,39 +15,39 @@ --> diff --git a/nodes/analysis/73-parsexml.js b/nodes/analysis/73-parsexml.js index 1cb9f61b7..0aa0846b1 100644 --- a/nodes/analysis/73-parsexml.js +++ b/nodes/analysis/73-parsexml.js @@ -19,27 +19,28 @@ var util = require("util"); var parseString = require('xml2js').parseString; var gotEyes = false; try { - var eyes = require("eyes"); - gotEyes = true; + var eyes = require("eyes"); + gotEyes = true; } catch(e) { - util.log("[73-parsexml.js] Warning: Module 'eyes' not installed"); + util.log("[73-parsexml.js] Note: Module 'eyes' not installed. (not needed, but useful)"); } function Xml2jsNode(n) { - RED.nodes.createNode(this,n); - this.useEyes = n.useEyes; - var node = this; - - this.on("input", function(msg) { - parseString(msg.payload, function (err, result) { - msg.payload = result; - node.send(msg); - if (node.useEyes == true) { - if (gotEyes == true) { eyes.inspect(msg); } - else { node.log(JSON.stringify(msg)); } - } - }); - }); + RED.nodes.createNode(this,n); + this.useEyes = n.useEyes; + var node = this; + this.on("input", function(msg) { + parseString(msg.payload, function (err, result) { + if (err) { node.error(err; } + else { + msg.payload = result; + node.send(msg); + if (node.useEyes == true) { + if (gotEyes == true) { eyes.inspect(msg); } + else { node.log(JSON.stringify(msg)); } + } + } + }); + }); } - RED.nodes.registerType("xml2js",Xml2jsNode); From ae13db90a930dc21cf4ebc213d10cf29d13d7468 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Tue, 22 Oct 2013 21:07:20 +0100 Subject: [PATCH 2/3] missing ; - oops --- nodes/analysis/73-parsexml.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/analysis/73-parsexml.js b/nodes/analysis/73-parsexml.js index 0aa0846b1..2d0e5225c 100644 --- a/nodes/analysis/73-parsexml.js +++ b/nodes/analysis/73-parsexml.js @@ -31,7 +31,7 @@ function Xml2jsNode(n) { var node = this; this.on("input", function(msg) { parseString(msg.payload, function (err, result) { - if (err) { node.error(err; } + if (err) { node.error(err); } else { msg.payload = result; node.send(msg); From dc0d62cb288d4a0c8cfb1fc618d171702804276e Mon Sep 17 00:00:00 2001 From: Nicholas O'Leary Date: Wed, 23 Oct 2013 00:03:09 +0100 Subject: [PATCH 3/3] HttpRequest: unable to overide url with https url --- nodes/io/21-httpin.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nodes/io/21-httpin.js b/nodes/io/21-httpin.js index 1bc527fda..109638cf9 100644 --- a/nodes/io/21-httpin.js +++ b/nodes/io/21-httpin.js @@ -79,7 +79,9 @@ function HTTPRequest(n) { var httplib = (/^https/.test(url))?https:http; var node = this; this.on("input",function(msg) { - + if (msg.url) { + httplib = (/^https/.test(msg.url))?https:http; + } var opts = urllib.parse(msg.url||url); opts.method = (msg.method||method).toUpperCase(); if (msg.headers) {