Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Commit 4622a36

Browse files
committed
🚑 Add missing 'content-length' header (possible fix for #135)
1 parent 065bfae commit 4622a36

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

nextcloud_backup/rootfs/opt/nextcloud_backup/tools/hassioApiTools.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function getVersion() {
2222
return new Promise((resolve, reject) => {
2323
let status = statusTools.getStatus();
2424
let option = {
25-
headers: { "Authorization": `Bearer ${token}` },
25+
headers: { "authorization": `Bearer ${token}` },
2626
responseType: "json",
2727
};
2828

@@ -48,7 +48,7 @@ function getAddonList() {
4848
return new Promise((resolve, reject) => {
4949
let status = statusTools.getStatus();
5050
let option = {
51-
headers: { "Authorization": `Bearer ${token}` },
51+
headers: { "authorization": `Bearer ${token}` },
5252
responseType: "json",
5353
};
5454

@@ -141,7 +141,7 @@ function getSnapshots() {
141141
return new Promise((resolve, reject) => {
142142
let status = statusTools.getStatus();
143143
let option = {
144-
headers: { "Authorization": `Bearer ${token}` },
144+
headers: { "authorization": `Bearer ${token}` },
145145
responseType: "json",
146146
};
147147

@@ -215,7 +215,7 @@ function dellSnap(id) {
215215
checkSnap(id)
216216
.then(() => {
217217
let option = {
218-
headers: { "Authorization": `Bearer ${token}` },
218+
headers: { "authorization": `Bearer ${token}` },
219219
responseType: "json",
220220
};
221221

@@ -235,7 +235,7 @@ function dellSnap(id) {
235235
function checkSnap(id) {
236236
return new Promise((resolve, reject) => {
237237
let option = {
238-
headers: { "Authorization": `Bearer ${token}` },
238+
headers: { "authorization": `Bearer ${token}` },
239239
responseType: "json",
240240
};
241241

@@ -258,7 +258,7 @@ function createNewBackup(name) {
258258
getAddonToBackup().then((addons) => {
259259
let folders = getFolderToBackup();
260260
let option = {
261-
headers: { "Authorization": `Bearer ${token}` },
261+
headers: { "authorization": `Bearer ${token}` },
262262
responseType: "json",
263263
timeout: {
264264
response: create_snap_timeout
@@ -332,7 +332,7 @@ function uploadSnapshot(path) {
332332

333333
let options = {
334334
body: form,
335-
headers: { "Authorization": `Bearer ${token}` },
335+
headers: { "authorization": `Bearer ${token}` },
336336
};
337337

338338
got.stream
@@ -386,7 +386,7 @@ function stopAddons() {
386386
statusTools.setStatus(status);
387387
let promises = [];
388388
let option = {
389-
headers: { "Authorization": `Bearer ${token}` },
389+
headers: { "authorization": `Bearer ${token}` },
390390
responseType: "json",
391391
};
392392
let addons_slug = settingsTools.getSettings().auto_stop_addon
@@ -426,7 +426,7 @@ function startAddons() {
426426
statusTools.setStatus(status);
427427
let promises = [];
428428
let option = {
429-
headers: { "Authorization": `Bearer ${token}` },
429+
headers: { "authorization": `Bearer ${token}` },
430430
responseType: "json",
431431
};
432432
let addons_slug = settingsTools.getSettings().auto_stop_addon
@@ -473,7 +473,7 @@ function publish_state(state) {
473473

474474

475475
// let option = {
476-
// headers: { "Authorization": `Bearer ${token}` },
476+
// headers: { "authorization": `Bearer ${token}` },
477477
// responseType: "json",
478478
// json: data_error_sensor
479479
// };

nextcloud_backup/rootfs/opt/nextcloud_backup/tools/webdavTools.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,16 @@ class WebdavTools {
214214
statusTools.setStatus(status);
215215
logger.info("Uploading snap...");
216216
let tmpFile = `./temp/${id}.tar`;
217+
let stats = fs.statSync(tmpFile);
217218
let stream = fs.createReadStream(tmpFile);
218219
let conf = this.getConf();
219220
let options = {
220221
body: stream,
221222
// username: this.username,
222223
// password: encodeURIComponent(this.password),
223224
headers: {
224-
'Authorization': 'Basic ' + Buffer.from(this.username + ':' + this.password).toString('base64')
225+
'authorization': 'Basic ' + Buffer.from(this.username + ':' + this.password).toString('base64'),
226+
'content-length': String(stats.size)
225227
}
226228
};
227229
if (conf.ssl === "true") {
@@ -321,7 +323,7 @@ class WebdavTools {
321323
let conf = this.getConf();
322324
let options = {
323325
headers: {
324-
'Authorization': 'Basic ' + Buffer.from(this.username + ':' + this.password).toString('base64')
326+
'authorization': 'Basic ' + Buffer.from(this.username + ':' + this.password).toString('base64')
325327
}
326328
};
327329
if (conf.ssl === "true") {

0 commit comments

Comments
 (0)