Added node warnings when message properties override set node properties

This commit is contained in:
Anna Thomas
2014-11-03 13:41:45 +00:00
parent 9f925140c9
commit 069a47f35a
6 changed files with 44 additions and 15 deletions

View File

@@ -118,8 +118,7 @@
<script type="text/x-red" data-help-name="http request">
<p>Provides a node for making http requests.</p>
<p>The URL and HTTP method can be configured in the node, but also
overridden by the incoming message:
<p>The URL and HTTP method can be configured in the node, if they are left blank they should be set in an incoming message on <code>msg.url</code> and <code>msg.method</code>:</p>
<ul>
<li><code>url</code>, if set, is used as the url of the request. Must start with http: or https:</li>
<li><code>method</code>, if set, is used as the HTTP method of the request.
@@ -157,7 +156,7 @@
return this.name;
} else if (this.url) {
var root = RED.settings.httpNodeRoot;
if (root.slice(-1) != "/") {
if (root.slice(-1) != "/") {
root = root+"/";
}
if (this.url.charAt(0) == "/") {
@@ -175,7 +174,7 @@
},
oneditprepare: function() {
var root = RED.settings.httpNodeRoot;
if (root.slice(-1) == "/") {
if (root.slice(-1) == "/") {
root = root.slice(0,-1);
}
if (root == "") {

View File

@@ -66,9 +66,9 @@ module.exports = function(RED) {
} else {
node.send({req:req,res:res});
}
}
};
var corsHandler = function(req,res,next) { next(); }
var corsHandler = function(req,res,next) { next(); };
if (RED.settings.httpNodeCors) {
corsHandler = cors(RED.settings.httpNodeCors);
@@ -154,6 +154,9 @@ module.exports = function(RED) {
node.status({fill:"blue",shape:"dot",text:"requesting"});
var url;
if (msg.url) {
if (n.url) {
node.warn("Deprecated: msg properties should not override set node properties. See bit.ly/nr-override-msg-props");
}
url = msg.url;
} else if (isTemplatedUrl) {
url = mustache.render(nodeUrl,msg);
@@ -165,7 +168,15 @@ module.exports = function(RED) {
url = "http://"+url;
}
var method = (msg.method||nodeMethod).toUpperCase();
var method;
if (msg.method) {
if (n.method) {
node.warn("Deprecated: msg properties should not override set node properties. See bit.ly/nr-override-msg-props");
}
method = msg.method.toUpperCase();
} else {
method = nodeMethod.toUpperCase();
}
//node.log(method+" : "+url);
var opts = urllib.parse(url);
opts.method = method;
@@ -240,4 +251,4 @@ module.exports = function(RED) {
password: {type: "password"}
}
});
}
};