1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

http request node add transport validity check and warn.

This commit is contained in:
Dave Conway-Jones 2017-05-15 22:04:47 +01:00
parent 5b5f9aa01d
commit 524021f0fa
No known key found for this signature in database
GPG Key ID: 81B04231572A9A2D
3 changed files with 11 additions and 3 deletions

View File

@ -103,7 +103,7 @@
name: {value:""},
method:{value:"GET"},
ret: {value:"txt"},
url:{value:""},
url:{value:"",validate:function(v) { return (v.trim().length === 0) || (v.indexOf("://") === -1) || (v.trim().indexOf("http") === 0)} },
tls: {type:"tls-config",required: false}
},
credentials: {
@ -112,6 +112,9 @@
},
inputs:1,
outputs:1,
outputLabels: function(i) {
return ({txt:"UTF8 string", bin:"binary buffer", obj:"parsed JSON object"}[this.ret]);
},
icon: "white-globe.png",
label: function() {
return this.name||this._("httpin.httpreq");

View File

@ -53,9 +53,13 @@ module.exports = function(RED) {
}
if (!url) {
node.error(RED._("httpin.errors.no-url"),msg);
return;
}
// url must start http:// or https:// so assume http:// if not set
if (url.indexOf("://") !== -1 && url.indexOf("http") !== 0) {
node.warn(RED._("httpin.errors.invalid-transport"));
node.status({fill:"red",shape:"ring",text:"httpin.errors.invalid-transport"});
return;
}
if (!((url.indexOf("http://") === 0) || (url.indexOf("https://") === 0))) {
if (tlsNode) {
url = "https://"+url;

View File

@ -355,7 +355,8 @@
"no-response": "No response object",
"json-error": "JSON parse error",
"no-url": "No url specified",
"deprecated-call":"Deprecated call to __method__"
"deprecated-call":"Deprecated call to __method__",
"invalid-transport":"non-http transport requested"
},
"status": {
"requesting": "requesting"