@@ -290,7 +291,7 @@
RED.tray.resize();
});
$("#node-input-method").on("change", function() {
- if ($(this).val() == "GET") {
+ if ($(this).val() == "GET" || $(this).val() == "use") {
$(".node-input-paytoqs-row").show();
} else {
$(".node-input-paytoqs-row").hide();
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 f7b17e6d1..911f4daba 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
@@ -16,7 +16,7 @@
module.exports = function(RED) {
"use strict";
- const got = require("got");
+ const got = require("got").default;
const {CookieJar} = require("tough-cookie");
const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent');
const FormData = require('form-data');
@@ -191,15 +191,21 @@ in your Node-RED user directory (${RED.settings.userDir}).
}
}
- /** @type {boolean|'query'|'body'} */
- let payloadHandling = node.paytoqs
let method = nodeMethod.toUpperCase() || "GET";
if (msg.method && n.method && (n.method !== "use")) { // warn if override option not set
node.warn(RED._("common.errors.nooverride"));
}
if (msg.method && n.method && (n.method === "use")) {
method = msg.method.toUpperCase(); // use the msg parameter
- payloadHandling = msg.payloadHandling
+ }
+
+ /** @type {boolean|'query'|'body'|'setby'} */
+ let payloadHandling = node.paytoqs
+ if (msg.payloadHandling && payloadHandling && (payloadHandling !== "setby")) { // warn if override option not set
+ node.warn(RED._("common.errors.nooverride"));
+ }
+ if (msg.payloadHandling && payloadHandling && (payloadHandling === "setby")) {
+ payloadHandling = msg.payloadHandling // use the msg parameter
}
if (payloadHandling === true) { payloadHandling = "query" }
diff --git a/packages/node_modules/@node-red/nodes/locales/de/messages.json b/packages/node_modules/@node-red/nodes/locales/de/messages.json
index 65f251e98..c09cced60 100755
--- a/packages/node_modules/@node-red/nodes/locales/de/messages.json
+++ b/packages/node_modules/@node-red/nodes/locales/de/messages.json
@@ -449,9 +449,11 @@
"headers": "Kopfzeilen",
"other": "andere",
"paytoqs": {
+ "label": "Payload (GET)",
"ignore": "Ignorieren",
"query": "Anfügen an query-string-Parameter",
- "body": "Senden als request-body"
+ "body": "Senden als request-body",
+ "setby": "Durch msg.payloadHandling festgelegt"
},
"utf8String": "UTF-8-String",
"binaryBuffer": "Binärer Buffer",
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 7fcd5eadc..f0094de8d 100644
--- a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json
+++ b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json
@@ -509,9 +509,11 @@
"headers": "Headers",
"other": "other",
"paytoqs": {
+ "label": "Payload (GET)",
"ignore": "Ignore",
"query": "Append to query-string parameters",
- "body": "Send as request body"
+ "body": "Send as request body",
+ "setby": "- set by msg.payloadHandling -"
},
"utf8String": "UTF8 string",
"binaryBuffer": "binary buffer",
diff --git a/packages/node_modules/@node-red/nodes/locales/en-US/network/21-httprequest.html b/packages/node_modules/@node-red/nodes/locales/en-US/network/21-httprequest.html
index b8d7fc048..4fb39ac71 100644
--- a/packages/node_modules/@node-red/nodes/locales/en-US/network/21-httprequest.html
+++ b/packages/node_modules/@node-red/nodes/locales/en-US/network/21-httprequest.html
@@ -30,6 +30,10 @@
If set, can be used to send cookies with the request.
payload
Sent as the body of the request.
+
payloadHandling string
+
Only valid with GET requests. If set to "- use msg.payloadHandling -" in the node configuration, this property
+ indicates how the payload will be sent. msg.payloadHandling should contain either
+ "query" or "body" otherwise the payload will not be sent with the GET request
rejectUnauthorized
If set to false, allows requests to be made to https sites that use
self signed certificates.
diff --git a/packages/node_modules/@node-red/nodes/locales/ja/messages.json b/packages/node_modules/@node-red/nodes/locales/ja/messages.json
index b7fa20b02..e722f5e19 100644
--- a/packages/node_modules/@node-red/nodes/locales/ja/messages.json
+++ b/packages/node_modules/@node-red/nodes/locales/ja/messages.json
@@ -509,9 +509,11 @@
"headers": "ヘッダ",
"other": "その他",
"paytoqs": {
+ "label": "ペイロード (GET)",
"ignore": "無視",
"query": "クエリパラメータに追加",
- "body": "リクエストボディとして送信"
+ "body": "リクエストボディとして送信",
+ "setby": "- msg.payloadHandlingに定義 -"
},
"utf8String": "UTF8文字列",
"binaryBuffer": "バイナリバッファ",
diff --git a/packages/node_modules/@node-red/nodes/locales/ko/messages.json b/packages/node_modules/@node-red/nodes/locales/ko/messages.json
index 15b7bee8e..2b0a88695 100755
--- a/packages/node_modules/@node-red/nodes/locales/ko/messages.json
+++ b/packages/node_modules/@node-red/nodes/locales/ko/messages.json
@@ -387,7 +387,13 @@
"status": "상태코드",
"headers": "헤더",
"other": "그 외",
- "paytoqs" : "msg.payload를 쿼리 파라미터에 추가",
+ "paytoqs": {
+ "label": "페이로드(GET)",
+ "ignore": "무시",
+ "query": "msg.payload를 쿼리 파라미터에 추가",
+ "body": "본문에 msg.payload 추가",
+ "setby": "- msg.payloadHandling에 의해 설정됨 -"
+ },
"utf8String": "UTF8문자열",
"binaryBuffer": "바이너리 버퍼",
"jsonObject": "JSON오브젝트",
diff --git a/packages/node_modules/@node-red/nodes/locales/ru/messages.json b/packages/node_modules/@node-red/nodes/locales/ru/messages.json
index 32364b458..b41be9457 100755
--- a/packages/node_modules/@node-red/nodes/locales/ru/messages.json
+++ b/packages/node_modules/@node-red/nodes/locales/ru/messages.json
@@ -411,9 +411,11 @@
"headers": "Заголовки",
"other": "другое",
"paytoqs": {
+ "label": "Данные (GET)",
"ignore": "Игнорировать",
"query": "Добавлять к параметрам строки запроса",
- "body": "Отправлять как тело запроса"
+ "body": "Отправлять как тело запроса",
+ "setby": "- устанавливается через msg.payloadHandling -"
},
"utf8String": "Строка UTF8",
"binaryBuffer": "двоичный буфер",
diff --git a/packages/node_modules/@node-red/nodes/locales/zh-CN/messages.json b/packages/node_modules/@node-red/nodes/locales/zh-CN/messages.json
index b649163b7..7d3775f8f 100644
--- a/packages/node_modules/@node-red/nodes/locales/zh-CN/messages.json
+++ b/packages/node_modules/@node-red/nodes/locales/zh-CN/messages.json
@@ -407,7 +407,13 @@
"status": "状态码",
"headers": "头",
"other": "其他",
- "paytoqs": "将msg.payload附加为查询字符串参数",
+ "paytoqs": {
+ "label": "有效负载(仅限 GET)",
+ "ignore": "漠视",
+ "query": "将msg.payload附加为查询字符串参数",
+ "body": "在请求正文中发送负载",
+ "setby": "- 用 msg.payloadHandling 设定 -"
+ },
"utf8String": "UTF8格式的字符串",
"binaryBuffer": "二进制buffer",
"jsonObject": "解析的JSON对象",
diff --git a/packages/node_modules/@node-red/nodes/locales/zh-TW/messages.json b/packages/node_modules/@node-red/nodes/locales/zh-TW/messages.json
index d63c47865..63f358b17 100644
--- a/packages/node_modules/@node-red/nodes/locales/zh-TW/messages.json
+++ b/packages/node_modules/@node-red/nodes/locales/zh-TW/messages.json
@@ -411,7 +411,13 @@
"status": "狀態碼",
"headers": "Header",
"other": "其他",
- "paytoqs": "將msg.payload附加為查詢字符串參數",
+ "paytoqs": {
+ "label": "有效負載(僅限 GET)",
+ "ignore": "漠視",
+ "query": "將msg.payload附加為查詢字符串參數",
+ "body": "在請求正文中發送負載",
+ "setby": "- 用 msg.payloadHandling 設定 -"
+ },
"utf8String": "UTF8格式的字符串",
"binaryBuffer": "二進制buffer",
"jsonObject": "解析的JSON對象",
diff --git a/test/nodes/core/network/21-httprequest_spec.js b/test/nodes/core/network/21-httprequest_spec.js
index b0307d7f4..412ef105a 100644
--- a/test/nodes/core/network/21-httprequest_spec.js
+++ b/test/nodes/core/network/21-httprequest_spec.js
@@ -299,10 +299,11 @@ describe('HTTP Request Node', function() {
// GOT never sent a body. (there is nothing in params/query/body)
// Oddly, if we set options.json (instead of options.body) in the GOT
// request, then req.body will have the values!
- // Has the 21-httprequest node ever been able to send a payload in body
- // for a GET request?
+ //I suspect the GOT lib *is* sending body on a GET request since an
+ // error is thrown if we try to set options.body on a GET request without
+ // setting options.allowGetBody to true.
res.json({
- // body:JSON.parse(req.body),
+ // body:JSON.parse(req.body), //req.body is empty!
url: req.originalUrl
});
})