node-red-contrib-hik-media-buffer 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hik-media-buffer.js +11 -2
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -44,15 +44,24 @@ module.exports = function(RED) {
|
|
|
44
44
|
|
|
45
45
|
async function hikRequest(options) {
|
|
46
46
|
const { method, url, data, responseType, user, pass, headers = {} } = options;
|
|
47
|
+
|
|
48
|
+
// Assicuriamoci che data sia una stringa se stiamo mandando XML
|
|
49
|
+
const body = (typeof data === 'object') ? JSON.stringify(data) : data;
|
|
50
|
+
|
|
47
51
|
const res = await urllib.request(url, {
|
|
48
52
|
method: method,
|
|
49
53
|
digestAuth: `${user}:${pass}`,
|
|
50
|
-
content:
|
|
51
|
-
headers:
|
|
54
|
+
content: body,
|
|
55
|
+
headers: {
|
|
56
|
+
'Content-Type': 'application/xml', // Questo dice alla telecamera: "Leggi l'XML"
|
|
57
|
+
'Accept': '*/*',
|
|
58
|
+
...headers
|
|
59
|
+
},
|
|
52
60
|
dataType: responseType === 'arraybuffer' ? 'buffer' : 'text',
|
|
53
61
|
timeout: 15000,
|
|
54
62
|
rejectUnauthorized: false
|
|
55
63
|
});
|
|
64
|
+
|
|
56
65
|
return res;
|
|
57
66
|
}
|
|
58
67
|
|