mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
First pass at adding support for GET requests
with a body
This commit is contained in:
parent
c9ad5bea93
commit
37bcd5c603
@ -33,8 +33,12 @@
|
||||
</div>
|
||||
|
||||
<div class="form-row node-input-paytoqs-row">
|
||||
<input type="checkbox" id="node-input-paytoqs" style="display: inline-block; width: auto; vertical-align: top;">
|
||||
<label for="node-input-paytoqs" style="width: auto" data-i18n="httpin.label.paytoqs"></label>
|
||||
<label for="node-input-paytox" style="width: auto" data-i18n="httpin.label.paytoqs"></label>
|
||||
<select id="node-input-paytox">
|
||||
<option value="ignore">Ignore</option>
|
||||
<option value="query">Query String</option>
|
||||
<option value="body">Request Body</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -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);
|
||||
@ -278,6 +279,14 @@ module.exports = function(RED) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// revert to user supplied Capitalisation if needed.
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user