2015-12-10 13:58:50 +01:00
|
|
|
<!--
|
2017-01-11 16:24:33 +01:00
|
|
|
Copyright JS Foundation and other contributors, http://js.foundation
|
2015-12-10 13:58:50 +01:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
-->
|
|
|
|
|
2020-01-15 03:40:48 +01:00
|
|
|
<script type="text/html" data-template-name="http request">
|
2015-12-10 13:58:50 +01:00
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-method"><i class="fa fa-tasks"></i> <span data-i18n="httpin.label.method"></span></label>
|
2016-06-27 00:48:59 +02:00
|
|
|
<select type="text" id="node-input-method" style="width:70%;">
|
2015-12-10 13:58:50 +01:00
|
|
|
<option value="GET">GET</option>
|
|
|
|
<option value="POST">POST</option>
|
|
|
|
<option value="PUT">PUT</option>
|
|
|
|
<option value="DELETE">DELETE</option>
|
2020-02-01 17:21:33 +01:00
|
|
|
<option value="HEAD">HEAD</option>
|
2015-12-10 13:58:50 +01:00
|
|
|
<option value="use" data-i18n="httpin.setby"></option>
|
|
|
|
</select>
|
|
|
|
</div>
|
2018-11-15 18:11:40 +01:00
|
|
|
|
2015-12-10 13:58:50 +01:00
|
|
|
<div class="form-row">
|
2016-09-08 21:49:44 +02:00
|
|
|
<label for="node-input-url"><i class="fa fa-globe"></i> <span data-i18n="httpin.label.url"></span></label>
|
2016-10-28 09:37:33 +02:00
|
|
|
<input id="node-input-url" type="text" placeholder="http://">
|
2015-12-10 13:58:50 +01:00
|
|
|
</div>
|
2016-04-27 13:31:54 +02:00
|
|
|
|
2019-02-04 22:30:11 +01:00
|
|
|
<div class="form-row node-input-paytoqs-row">
|
2020-05-29 18:35:18 +02:00
|
|
|
<label for="node-input-paytoqs"><span data-i18n="common.label.payload"></span></label>
|
2020-02-26 20:45:01 +01:00
|
|
|
<select id="node-input-paytoqs" style="width: 70%;">
|
|
|
|
<option value="ignore" data-i18n="httpin.label.paytoqs.ignore"></option>
|
|
|
|
<option value="query" data-i18n="httpin.label.paytoqs.query"></option>
|
|
|
|
<option value="body" data-i18n="httpin.label.paytoqs.body"></option>
|
2020-02-25 22:28:15 +01:00
|
|
|
</select>
|
2018-11-15 18:11:40 +01:00
|
|
|
</div>
|
|
|
|
|
2016-04-27 13:31:54 +02:00
|
|
|
<div class="form-row">
|
|
|
|
<input type="checkbox" id="node-input-usetls" style="display: inline-block; width: auto; vertical-align: top;">
|
|
|
|
<label for="node-input-usetls" style="width: auto" data-i18n="httpin.use-tls"></label>
|
|
|
|
<div id="node-row-tls" class="hide">
|
|
|
|
<label style="width: auto; margin-left: 20px; margin-right: 10px;" for="node-input-tls"><span data-i18n="httpin.tls-config"></span></label><input type="text" style="width: 300px" id="node-input-tls">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2015-12-10 13:58:50 +01:00
|
|
|
<div class="form-row">
|
|
|
|
<input type="checkbox" id="node-input-useAuth" style="display: inline-block; width: auto; vertical-align: top;">
|
|
|
|
<label for="node-input-useAuth" style="width: 70%;"><span data-i18n="httpin.basicauth"></span></label>
|
2016-04-27 13:31:54 +02:00
|
|
|
<div style="margin-left: 20px" class="node-input-useAuth-row hide">
|
|
|
|
<div class="form-row">
|
2019-06-20 23:33:38 +02:00
|
|
|
<label for="node-input-authType-select"><i class="fa fa-user-secret "></i> <span data-i18n="httpin.label.authType"></span></label>
|
|
|
|
<select type="text" id="node-input-authType-select" style="width:70%;">
|
2019-02-27 23:15:31 +01:00
|
|
|
<option value="basic" data-i18n="httpin.basic"></option>
|
|
|
|
<option value="digest" data-i18n="httpin.digest"></option>
|
|
|
|
<option value="bearer" data-i18n="httpin.bearer"></option>
|
|
|
|
</select>
|
2019-06-20 23:33:38 +02:00
|
|
|
<input type="hidden" id="node-input-authType">
|
2019-02-27 23:15:31 +01:00
|
|
|
</div>
|
|
|
|
<div class="form-row node-input-basic-row">
|
2016-04-27 13:31:54 +02:00
|
|
|
<label for="node-input-user"><i class="fa fa-user"></i> <span data-i18n="common.label.username"></span></label>
|
|
|
|
<input type="text" id="node-input-user">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2019-03-01 23:18:48 +01:00
|
|
|
<label for="node-input-password"> <i class="fa fa-lock"></i> <span data-i18n="common.label.password" id="node-span-password"></span><span data-i18n="httpin.label.bearerToken" id="node-span-token" style="display:none"></span></label>
|
2016-04-27 13:31:54 +02:00
|
|
|
<input type="password" id="node-input-password">
|
|
|
|
</div>
|
|
|
|
</div>
|
2015-12-10 13:58:50 +01:00
|
|
|
</div>
|
2019-08-21 12:45:21 +02:00
|
|
|
|
2019-08-09 20:26:14 +02:00
|
|
|
<div class="form-row">
|
2019-08-12 21:50:37 +02:00
|
|
|
<input type="checkbox" id="node-input-persist" style="display: inline-block; width: auto; vertical-align: top;">
|
|
|
|
<label for="node-input-persist" style="width: auto" data-i18n="httpin.persist"></label>
|
2019-08-09 20:26:14 +02:00
|
|
|
</div>
|
2016-04-27 13:31:54 +02:00
|
|
|
|
2018-10-03 02:58:25 +02:00
|
|
|
<div class="form-row">
|
|
|
|
<input type="checkbox" id="node-input-useProxy" style="display: inline-block; width: auto; vertical-align: top;">
|
|
|
|
<label for="node-input-useProxy" style="width: auto;"><span data-i18n="httpin.use-proxy"></span></label>
|
|
|
|
<div id="node-input-useProxy-row" class="hide">
|
|
|
|
<label style="width: auto; margin-left: 20px; margin-right: 10px;" for="node-input-proxy"><i class="fa fa-globe"></i> <span data-i18n="httpin.proxy-config"></span></label><input type="text" style="width: 270px" id="node-input-proxy">
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-04-27 13:31:54 +02:00
|
|
|
|
2021-10-04 15:04:59 +02:00
|
|
|
<div class="form-row">
|
|
|
|
<input type="checkbox" id="node-input-senderr" style="display: inline-block; width: auto; vertical-align: top;">
|
|
|
|
<label for="node-input-senderr" style="width: auto" data-i18n="httpin.senderr"></label>
|
|
|
|
</div>
|
|
|
|
|
2022-07-16 20:51:35 +02:00
|
|
|
<div class="form-row">
|
|
|
|
<input type="checkbox" id="node-input-insecureHTTPParser" style="display: inline-block; width: auto; vertical-align: top;">
|
|
|
|
<label for="node-input-insecureHTTPParser", style="width: auto;" data-i18n="httpin.insecureHTTPParser"></label>
|
|
|
|
</div>
|
|
|
|
|
2021-10-04 15:04:59 +02:00
|
|
|
|
2015-12-10 13:58:50 +01:00
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-ret"><i class="fa fa-arrow-left"></i> <span data-i18n="httpin.label.return"></span></label>
|
2016-06-27 00:48:59 +02:00
|
|
|
<select type="text" id="node-input-ret" style="width:70%;">
|
2015-12-10 13:58:50 +01:00
|
|
|
<option value="txt" data-i18n="httpin.utf8"></option>
|
|
|
|
<option value="bin" data-i18n="httpin.binary"></option>
|
|
|
|
<option value="obj" data-i18n="httpin.json"></option>
|
|
|
|
</select>
|
|
|
|
</div>
|
2022-03-12 15:59:15 +01:00
|
|
|
|
|
|
|
<div class="form-row form-tips" id="tip-json" hidden><span data-i18n="httpin.tip.req"></span></div>
|
|
|
|
|
2022-03-12 14:47:29 +01:00
|
|
|
<div class="form-row" style="margin-bottom:0;">
|
|
|
|
<label><i class="fa fa-list"></i> <span data-i18n="httpin.label.headers"></span></label>
|
|
|
|
</div>
|
|
|
|
<div class="form-row node-input-headers-container-row">
|
|
|
|
<ol id="node-input-headers-container"></ol>
|
|
|
|
</div>
|
2022-03-12 15:59:15 +01:00
|
|
|
|
2015-12-10 13:58:50 +01:00
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
|
|
|
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
|
|
|
</div>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2022-03-12 14:47:29 +01:00
|
|
|
(function() {
|
|
|
|
const headerTypes = [
|
|
|
|
{ value: "Accept", label: "Accept", hasValue: false },
|
|
|
|
{ value: "Accept-Encoding", label: "Accept-Encoding", hasValue: false },
|
|
|
|
{ value: "Accept-Language", label: "Accept-Language", hasValue: false },
|
|
|
|
{ value: "Authorization", label: "Authorization", hasValue: false },
|
2022-03-12 16:00:48 +01:00
|
|
|
{ value: "Content-Type", label: "Content-Type", hasValue: false },
|
2022-03-12 14:47:29 +01:00
|
|
|
{ value: "Cache-Control", label: "Cache-Control", hasValue: false },
|
|
|
|
{ value: "User-Agent", label: "User-Agent", hasValue: false },
|
2022-03-12 16:00:48 +01:00
|
|
|
{ value: "Location", label: "Location", hasValue: false },
|
2022-05-04 16:54:23 +02:00
|
|
|
{ value: "other", label: RED._("node-red:httpin.label.other"),
|
2022-05-04 18:20:41 +02:00
|
|
|
hasValue: true, icon: "red/images/typedInput/az.svg" },
|
2022-03-12 14:47:29 +01:00
|
|
|
{ value: "msg", label: "msg.", hasValue: true },
|
|
|
|
]
|
|
|
|
const headerOptions = {};
|
|
|
|
const defaultOptions = [
|
2022-05-04 16:54:23 +02:00
|
|
|
{ value: "other", label: RED._("node-red:httpin.label.other"),
|
2022-05-04 18:20:41 +02:00
|
|
|
hasValue: true, icon: "red/images/typedInput/az.svg" },
|
2022-03-12 14:47:29 +01:00
|
|
|
{ value: "msg", label: "msg.", hasValue: true },
|
|
|
|
];
|
|
|
|
headerOptions["accept"] = [
|
|
|
|
{ value: "text/plain", label: "text/plain", hasValue: false },
|
|
|
|
{ value: "text/html", label: "text/html", hasValue: false },
|
|
|
|
{ value: "application/json", label: "application/json", hasValue: false },
|
|
|
|
{ value: "application/xml", label: "application/xml", hasValue: false },
|
|
|
|
...defaultOptions,
|
|
|
|
];
|
|
|
|
headerOptions["accept-encoding"] = [
|
|
|
|
{ value: "gzip", label: "gzip", hasValue: false },
|
|
|
|
{ value: "deflate", label: "deflate", hasValue: false },
|
2022-03-12 16:00:48 +01:00
|
|
|
{ value: "compress", label: "compress", hasValue: false },
|
|
|
|
{ value: "br", label: "br", hasValue: false },
|
2022-03-12 14:47:29 +01:00
|
|
|
{ value: "gzip, deflate", label: "gzip, deflate", hasValue: false },
|
|
|
|
{ value: "gzip, deflate, br", label: "gzip, deflate, br", hasValue: false },
|
|
|
|
...defaultOptions,
|
|
|
|
];
|
|
|
|
headerOptions["accept-language"] = [
|
|
|
|
{ value: "*", label: "*", hasValue: false },
|
|
|
|
{ value: "en-GB, en-US, en;q=0.9", label: "en-GB, en-US, en;q=0.9", hasValue: false },
|
|
|
|
{ value: "de-AT, de-DE;q=0.9, en;q=0.5", label: "de-AT, de-DE;q=0.9, en;q=0.5", hasValue: false },
|
|
|
|
{ value: "es-mx,es,en;q=0.5", label: "es-mx,es,en;q=0.5", hasValue: false },
|
|
|
|
{ value: "fr-CH, fr;q=0.9, en;q=0.8", label: "fr-CH, fr;q=0.9, en;q=0.8", hasValue: false },
|
|
|
|
{ value: "zh-CN, zh-TW; q = 0.9, zh-HK; q = 0.8, zh; q = 0.7, en; q = 0.6", label: "zh-CN, zh-TW; q = 0.9, zh-HK; q = 0.8, zh; q = 0.7, en; q = 0.6", hasValue: false },
|
2022-03-12 16:00:48 +01:00
|
|
|
{ value: "ja-JP, jp", label: "ja-JP, jp", hasValue: false },
|
2022-03-12 14:47:29 +01:00
|
|
|
...defaultOptions,
|
|
|
|
];
|
|
|
|
headerOptions["content-type"] = [
|
|
|
|
{ value: "text/css", label: "text/css", hasValue: false },
|
|
|
|
{ value: "text/plain", label: "text/plain", hasValue: false },
|
|
|
|
{ value: "text/html", label: "text/html", hasValue: false },
|
|
|
|
{ value: "application/json", label: "application/json", hasValue: false },
|
|
|
|
{ value: "application/octet-stream", label: "application/octet-stream", hasValue: false },
|
|
|
|
{ value: "application/pdf", label: "application/pdf", hasValue: false },
|
|
|
|
{ value: "application/xml", label: "application/xml", hasValue: false },
|
|
|
|
{ value: "application/zip", label: "application/zip", hasValue: false },
|
|
|
|
{ value: "multipart/form-data", label: "multipart/form-data", hasValue: false },
|
|
|
|
{ value: "audio/aac", label: "audio/aac", hasValue: false },
|
|
|
|
{ value: "audio/ac3", label: "audio/ac3", hasValue: false },
|
|
|
|
{ value: "audio/basic", label: "audio/basic", hasValue: false },
|
|
|
|
{ value: "audio/mp4", label: "audio/mp4", hasValue: false },
|
|
|
|
{ value: "audio/ogg", label: "audio/ogg", hasValue: false },
|
|
|
|
{ value: "image/bmp", label: "image/bmp", hasValue: false },
|
|
|
|
{ value: "image/gif", label: "image/gif", hasValue: false },
|
|
|
|
{ value: "image/jpeg", label: "image/jpeg", hasValue: false },
|
|
|
|
{ value: "image/png", label: "image/png", hasValue: false },
|
|
|
|
{ value: "image/tiff", label: "image/tiff", hasValue: false },
|
|
|
|
...defaultOptions,
|
|
|
|
];
|
|
|
|
headerOptions["cache-control"] = [
|
|
|
|
{ value: "max-age=0", label: "max-age=0", hasValue: false },
|
|
|
|
{ value: "max-age=86400", label: "max-age=86400", hasValue: false },
|
|
|
|
{ value: "no-cache", label: "no-cache", hasValue: false },
|
|
|
|
...defaultOptions,
|
|
|
|
];
|
|
|
|
|
|
|
|
headerOptions["user-agent"] = [
|
|
|
|
{ value: "Mozilla/5.0", label: "Mozilla/5.0", hasValue: false },
|
|
|
|
...defaultOptions,
|
|
|
|
];
|
|
|
|
|
|
|
|
function getHeaderOptions(headerName) {
|
|
|
|
const lc = (headerName || "").toLowerCase();
|
|
|
|
let opts = headerOptions[lc];
|
|
|
|
return opts || defaultOptions;
|
|
|
|
}
|
|
|
|
|
2015-12-10 13:58:50 +01:00
|
|
|
RED.nodes.registerType('http request',{
|
2019-08-21 15:21:19 +02:00
|
|
|
category: 'network',
|
2015-12-10 13:58:50 +01:00
|
|
|
color:"rgb(231, 231, 174)",
|
|
|
|
defaults: {
|
|
|
|
name: {value:""},
|
|
|
|
method:{value:"GET"},
|
|
|
|
ret: {value:"txt"},
|
2019-02-04 22:30:11 +01:00
|
|
|
paytoqs: {value: false},
|
2022-02-14 02:40:49 +01:00
|
|
|
url:{
|
|
|
|
value:"",
|
|
|
|
validate: function(v, opt) {
|
|
|
|
if ((v.trim().length === 0) ||
|
|
|
|
(v.indexOf("://") === -1) ||
|
|
|
|
(v.trim().indexOf("http") === 0)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return RED._("node-red:httpin.errors.invalid-url");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tls: {type:"tls-config",required: false,
|
|
|
|
label:RED._("node-red:httpin.tls-config") },
|
2019-08-21 12:45:21 +02:00
|
|
|
persist: {value:false},
|
2022-02-14 02:40:49 +01:00
|
|
|
proxy: {type:"http proxy",required: false,
|
|
|
|
label:RED._("node-red:httpin.proxy-config") },
|
2022-07-16 20:51:35 +02:00
|
|
|
insecureHTTPParser: {value: false},
|
2021-10-04 15:04:59 +02:00
|
|
|
authType: {value: ""},
|
2022-03-12 14:47:29 +01:00
|
|
|
senderr: {value: false},
|
|
|
|
headers: { value: [] }
|
2015-12-10 13:58:50 +01:00
|
|
|
},
|
|
|
|
credentials: {
|
|
|
|
user: {type:"text"},
|
|
|
|
password: {type: "password"}
|
|
|
|
},
|
|
|
|
inputs:1,
|
|
|
|
outputs:1,
|
2017-05-15 23:04:47 +02:00
|
|
|
outputLabels: function(i) {
|
2019-02-28 12:22:33 +01:00
|
|
|
return ({
|
|
|
|
txt: this._("httpin.label.utf8String"),
|
|
|
|
bin: this._("httpin.label.binaryBuffer"),
|
|
|
|
obj: this._("httpin.label.jsonObject")
|
|
|
|
}[this.ret]);
|
2017-05-15 23:04:47 +02:00
|
|
|
},
|
2019-06-21 13:36:20 +02:00
|
|
|
icon: "white-globe.svg",
|
2015-12-10 13:58:50 +01:00
|
|
|
label: function() {
|
|
|
|
return this.name||this._("httpin.httpreq");
|
|
|
|
},
|
|
|
|
labelStyle: function() {
|
|
|
|
return this.name?"node_label_italic":"";
|
|
|
|
},
|
|
|
|
oneditprepare: function() {
|
2022-03-12 14:47:29 +01:00
|
|
|
const node = this;
|
2019-04-29 12:50:15 +02:00
|
|
|
$("#node-input-useAuth").on("change", function() {
|
2015-12-10 13:58:50 +01:00
|
|
|
if ($(this).is(":checked")) {
|
|
|
|
$(".node-input-useAuth-row").show();
|
2019-02-27 23:15:31 +01:00
|
|
|
// Nodes (< version 0.20.x) with credentials but without authentication type, need type 'basic'
|
|
|
|
if (!$('#node-input-authType').val()) {
|
2019-06-20 23:33:38 +02:00
|
|
|
$("#node-input-authType-select").val('basic').trigger("change");
|
2019-02-27 23:15:31 +01:00
|
|
|
}
|
2015-12-10 13:58:50 +01:00
|
|
|
} else {
|
|
|
|
$(".node-input-useAuth-row").hide();
|
2019-02-27 23:15:31 +01:00
|
|
|
$('#node-input-authType').val('');
|
2015-12-10 13:58:50 +01:00
|
|
|
$('#node-input-user').val('');
|
|
|
|
$('#node-input-password').val('');
|
|
|
|
}
|
2022-03-12 14:47:29 +01:00
|
|
|
RED.tray.resize();
|
2015-12-10 13:58:50 +01:00
|
|
|
});
|
2019-06-21 15:01:34 +02:00
|
|
|
$("#node-input-authType-select").on("change", function() {
|
2022-03-12 16:02:25 +01:00
|
|
|
const val = $(this).val();
|
2019-06-20 23:33:38 +02:00
|
|
|
$("#node-input-authType").val(val);
|
|
|
|
if (val === "basic" || val === "digest") {
|
2019-02-27 23:15:31 +01:00
|
|
|
$(".node-input-basic-row").show();
|
|
|
|
$('#node-span-password').show();
|
|
|
|
$('#node-span-token').hide();
|
2019-06-20 23:33:38 +02:00
|
|
|
} else if (val === "bearer") {
|
2019-02-27 23:15:31 +01:00
|
|
|
$(".node-input-basic-row").hide();
|
|
|
|
$('#node-span-password').hide();
|
|
|
|
$('#node-span-token').show();
|
|
|
|
$('#node-input-user').val('');
|
|
|
|
}
|
2022-03-12 14:47:29 +01:00
|
|
|
RED.tray.resize();
|
2019-02-27 23:15:31 +01:00
|
|
|
});
|
2019-04-29 12:50:15 +02:00
|
|
|
$("#node-input-method").on("change", function() {
|
2018-11-15 18:11:40 +01:00
|
|
|
if ($(this).val() == "GET") {
|
2019-02-04 22:30:11 +01:00
|
|
|
$(".node-input-paytoqs-row").show();
|
2018-11-15 18:11:40 +01:00
|
|
|
} else {
|
2019-02-04 22:30:11 +01:00
|
|
|
$(".node-input-paytoqs-row").hide();
|
2018-11-15 18:11:40 +01:00
|
|
|
}
|
2022-03-12 14:47:29 +01:00
|
|
|
RED.tray.resize();
|
2018-11-15 18:11:40 +01:00
|
|
|
});
|
2022-03-12 14:47:29 +01:00
|
|
|
if (node.paytoqs === true || node.paytoqs == "query") {
|
2020-02-26 20:45:01 +01:00
|
|
|
$("#node-input-paytoqs").val("query");
|
2022-03-12 14:47:29 +01:00
|
|
|
} else if (node.paytoqs === "body") {
|
2020-02-26 20:45:01 +01:00
|
|
|
$("#node-input-paytoqs").val("body");
|
2020-02-25 22:28:15 +01:00
|
|
|
} else {
|
2020-02-26 20:45:01 +01:00
|
|
|
$("#node-input-paytoqs").val("ignore");
|
2020-02-25 22:28:15 +01:00
|
|
|
}
|
2022-03-12 14:47:29 +01:00
|
|
|
if (node.authType) {
|
2016-04-27 13:31:54 +02:00
|
|
|
$('#node-input-useAuth').prop('checked', true);
|
2022-03-12 14:47:29 +01:00
|
|
|
$("#node-input-authType-select").val(node.authType);
|
2019-10-19 14:16:03 +02:00
|
|
|
$("#node-input-authType-select").change();
|
2016-04-27 13:31:54 +02:00
|
|
|
} else {
|
|
|
|
$('#node-input-useAuth').prop('checked', false);
|
|
|
|
}
|
|
|
|
$("#node-input-useAuth").change();
|
2015-12-10 13:58:50 +01:00
|
|
|
|
2016-04-27 13:31:54 +02:00
|
|
|
function updateTLSOptions() {
|
|
|
|
if ($("#node-input-usetls").is(':checked')) {
|
|
|
|
$("#node-row-tls").show();
|
|
|
|
} else {
|
|
|
|
$("#node-row-tls").hide();
|
|
|
|
}
|
2022-03-12 14:47:29 +01:00
|
|
|
RED.tray.resize();
|
2016-04-27 13:31:54 +02:00
|
|
|
}
|
2022-03-12 14:47:29 +01:00
|
|
|
if (node.tls) {
|
2016-04-27 13:31:54 +02:00
|
|
|
$('#node-input-usetls').prop('checked', true);
|
|
|
|
} else {
|
|
|
|
$('#node-input-usetls').prop('checked', false);
|
|
|
|
}
|
|
|
|
updateTLSOptions();
|
|
|
|
$("#node-input-usetls").on("click",function() {
|
|
|
|
updateTLSOptions();
|
|
|
|
});
|
2018-10-03 02:58:25 +02:00
|
|
|
|
|
|
|
function updateProxyOptions() {
|
|
|
|
if ($("#node-input-useProxy").is(":checked")) {
|
|
|
|
$("#node-input-useProxy-row").show();
|
|
|
|
} else {
|
|
|
|
$("#node-input-useProxy-row").hide();
|
|
|
|
}
|
2022-03-12 14:47:29 +01:00
|
|
|
RED.tray.resize();
|
2018-10-03 02:58:25 +02:00
|
|
|
}
|
2022-03-12 14:47:29 +01:00
|
|
|
if (node.proxy) {
|
2018-10-03 02:58:25 +02:00
|
|
|
$("#node-input-useProxy").prop("checked", true);
|
|
|
|
} else {
|
|
|
|
$("#node-input-useProxy").prop("checked", false);
|
|
|
|
}
|
2022-07-16 20:51:35 +02:00
|
|
|
|
|
|
|
if (node.insecureHTTPParser) {
|
|
|
|
$("node-intput-insecureHTTPParser").prop("checked", true)
|
|
|
|
} else {
|
|
|
|
$("node-intput-insecureHTTPParser").prop("checked", false)
|
|
|
|
}
|
2018-10-03 02:58:25 +02:00
|
|
|
updateProxyOptions();
|
|
|
|
$("#node-input-useProxy").on("click", function() {
|
|
|
|
updateProxyOptions();
|
|
|
|
});
|
|
|
|
|
2019-04-29 12:50:15 +02:00
|
|
|
$("#node-input-ret").on("change", function() {
|
2015-12-10 13:58:50 +01:00
|
|
|
if ($("#node-input-ret").val() === "obj") {
|
|
|
|
$("#tip-json").show();
|
|
|
|
} else {
|
|
|
|
$("#tip-json").hide();
|
|
|
|
}
|
2022-03-12 14:47:29 +01:00
|
|
|
RED.tray.resize();
|
2015-12-10 13:58:50 +01:00
|
|
|
});
|
2022-03-12 14:47:29 +01:00
|
|
|
const hasMatch = function (arr, value) {
|
|
|
|
return arr.some(function (ht) {
|
|
|
|
return ht.value === value
|
|
|
|
});
|
|
|
|
}
|
|
|
|
const headerList = $("#node-input-headers-container").css('min-height', '150px').css('min-width', '450px').editableList({
|
|
|
|
addItem: function (container, i, header) {
|
|
|
|
const row = $('<div/>').css({
|
|
|
|
overflow: 'hidden',
|
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
display: 'flex'
|
|
|
|
}).appendTo(container);
|
|
|
|
const propertNameCell = $('<div/>').css({ 'flex-grow': 1 }).appendTo(row);
|
|
|
|
const propertyName = $('<input/>', { class: "node-input-header-name", type: "text", style: "width: 100%" })
|
|
|
|
.appendTo(propertNameCell)
|
|
|
|
.typedInput({ types: headerTypes });
|
|
|
|
|
|
|
|
const propertyValueCell = $('<div/>').css({ 'flex-grow': 1, 'margin-left': '10px' }).appendTo(row);
|
|
|
|
const propertyValue = $('<input/>', { class: "node-input-header-value", type: "text", style: "width: 100%" })
|
|
|
|
.appendTo(propertyValueCell)
|
|
|
|
.typedInput({
|
|
|
|
types: getHeaderOptions(header.keyType)
|
|
|
|
});
|
|
|
|
|
|
|
|
const setup = function(_header) {
|
|
|
|
const headerTypeIsAPreset = function(h) {return hasMatch(headerTypes, h) };
|
|
|
|
const headerValueIsAPreset = function(h, v) {return hasMatch(getHeaderOptions(h), v) };
|
|
|
|
const {keyType, keyValue, valueType, valueValue} = header;
|
|
|
|
if(keyType == "msg" || keyType == "other") {
|
|
|
|
propertyName.typedInput('type', keyType);
|
|
|
|
propertyName.typedInput('value', keyValue);
|
|
|
|
} else if (headerTypeIsAPreset(keyType)) {
|
|
|
|
propertyName.typedInput('type', keyType);
|
|
|
|
} else {
|
|
|
|
propertyName.typedInput('type', "other");
|
|
|
|
propertyName.typedInput('value', keyValue);
|
|
|
|
}
|
|
|
|
if(valueType == "msg" || valueType == "other") {
|
|
|
|
propertyValue.typedInput('type', valueType);
|
|
|
|
propertyValue.typedInput('value', valueValue);
|
|
|
|
} else if (headerValueIsAPreset(propertyName.typedInput('type'), valueType)) {
|
|
|
|
propertyValue.typedInput('type', valueType);
|
|
|
|
} else {
|
|
|
|
propertyValue.typedInput('type', "other");
|
|
|
|
propertyValue.typedInput('value', valueValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setup(header);
|
|
|
|
|
|
|
|
propertyName.on('change', function (event) {
|
|
|
|
propertyValue.typedInput('types', getHeaderOptions(propertyName.typedInput('type')));
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
2022-08-17 18:29:07 +02:00
|
|
|
sortable: true,
|
2022-03-12 14:47:29 +01:00
|
|
|
removable: true
|
2015-12-10 13:58:50 +01:00
|
|
|
});
|
2022-03-12 14:47:29 +01:00
|
|
|
if (node.headers) {
|
|
|
|
for (let index = 0; index < node.headers.length; index++) {
|
|
|
|
const element = node.headers[index];
|
|
|
|
headerList.editableList('addItem', node.headers[index]);
|
|
|
|
}
|
|
|
|
}
|
2016-04-27 13:31:54 +02:00
|
|
|
},
|
|
|
|
oneditsave: function() {
|
|
|
|
if (!$("#node-input-usetls").is(':checked')) {
|
|
|
|
$("#node-input-tls").val("_ADD_");
|
|
|
|
}
|
2018-10-03 02:58:25 +02:00
|
|
|
if (!$("#node-input-useProxy").is(":checked")) {
|
|
|
|
$("#node-input-proxy").val("_ADD_");
|
|
|
|
}
|
2022-03-12 14:47:29 +01:00
|
|
|
const headers = $("#node-input-headers-container").editableList('items');
|
|
|
|
const node = this;
|
|
|
|
node.headers = [];
|
|
|
|
headers.each(function(i) {
|
2022-03-12 17:10:36 +01:00
|
|
|
const header = $(this);
|
2022-03-12 14:47:29 +01:00
|
|
|
const keyType = header.find(".node-input-header-name").typedInput('type');
|
|
|
|
const keyValue = header.find(".node-input-header-name").typedInput('value');
|
|
|
|
const valueType = header.find(".node-input-header-value").typedInput('type');
|
|
|
|
const valueValue = header.find(".node-input-header-value").typedInput('value');
|
|
|
|
if (keyType !== '' || keyType === 'other' || keyType === 'msg') {
|
|
|
|
node.headers.push({
|
|
|
|
keyType, keyValue, valueType, valueValue
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
oneditresize: function(size) {
|
|
|
|
const dlg = $("#dialog-form");
|
|
|
|
const expandRow = dlg.find('.node-input-headers-container-row');
|
|
|
|
let height = dlg.height() - 5;
|
|
|
|
if(expandRow && expandRow.length){
|
|
|
|
const siblingRows = dlg.find('> .form-row:not(.node-input-headers-container-row)');
|
|
|
|
for (let i = 0; i < siblingRows.size(); i++) {
|
|
|
|
const cr = $(siblingRows[i]);
|
|
|
|
if(cr.is(":visible"))
|
|
|
|
height -= cr.outerHeight(true);
|
|
|
|
}
|
|
|
|
$("#node-input-headers-container").editableList('height',height);
|
|
|
|
}
|
2015-12-10 13:58:50 +01:00
|
|
|
}
|
|
|
|
});
|
2022-03-12 14:47:29 +01:00
|
|
|
})();
|
2015-12-10 13:58:50 +01:00
|
|
|
</script>
|