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:
parent
5b5f9aa01d
commit
524021f0fa
@ -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");
|
||||
|
@ -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;
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user