diff --git a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.html b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.html index aecb8eeb9..d2cc61b56 100644 --- a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.html +++ b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.html @@ -33,8 +33,12 @@
- - + +
@@ -106,6 +110,7 @@ method:{value:"GET"}, ret: {value:"txt"}, paytoqs: {value: false}, + paytobody: {value: false}, url:{value:"",validate:function(v) { return (v.trim().length === 0) || (v.indexOf("://") === -1) || (v.trim().indexOf("http") === 0)} }, tls: {type:"tls-config",required: false}, persist: {value:false}, @@ -168,6 +173,13 @@ $(".node-input-paytoqs-row").hide(); } }); + if (this.paytoqs) { + $("#node-input-paytox").val("query"); + } else if (this.paytobody) { + $("#node-input-paytox").val("body"); + } else { + $("#node-input-paytox").val("ignore"); + } if (this.authType) { $('#node-input-useAuth').prop('checked', true); $("#node-input-authType-select").val(this.authType); @@ -226,6 +238,18 @@ if (!$("#node-input-useProxy").is(":checked")) { $("#node-input-proxy").val("_ADD_"); } + + var payto = $("#node-input-paytox").val(); + if(payto == "query") { + this.paytoqs = true; + this.paytobody = false; + } else if (payto == "body") { + this.paytoqs = false; + this.paytobody = true; + } else { + this.paytoqs = false; + this.paytobody = false; + } } }); diff --git a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js index 4c39f9f8c..5d911bffe 100644 --- a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js +++ b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js @@ -29,6 +29,7 @@ module.exports = function(RED) { var isTemplatedUrl = (nodeUrl||"").indexOf("{{") != -1; var nodeMethod = n.method || "GET"; var paytoqs = n.paytoqs; + var paytobody = n.paytobody; var nodeHTTPPersistent = n["persist"]; if (n.tls) { var tlsNode = RED.nodes.getNode(n.tls); @@ -277,6 +278,14 @@ module.exports = function(RED) { node.error(RED._("httpin.errors.invalid-payload"),msg); nodeDone(); return; + } + } else if ( method == "GET" && typeof msg.payload !== "undefined" && paytobody) { + if (typeof msg.payload === "object") { + opts.body = JSON.stringify(msg.payload); + } else if (typeof msg.payload == "number") { + opts.body = msg.payload+""; + } else if (typeof msg.payload === "string" || Buffer.isBuffer(msg.payload)) { + opts.body = msg.payload; } } diff --git a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json index e1d7c6368..94d541444 100755 --- a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json @@ -398,7 +398,7 @@ "status": "Status code", "headers": "Headers", "other": "other", - "paytoqs" : "Append msg.payload as query string parameters", + "paytoqs" : "Append msg.payload as", "utf8String": "UTF8 string", "binaryBuffer": "binary buffer", "jsonObject": "parsed JSON object",