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.
@@ -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: data,
51
- headers: 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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-hik-media-buffer",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Ottiene buffer video e immagine da camere Hikvision via ISAPI",
5
5
  "keywords": [
6
6
  "node-red",