Skip to content

Commit

Permalink
🚑 Add missing 'content-length' header (possible fix for #135)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebclem committed May 3, 2022
1 parent 065bfae commit 4622a36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function getVersion() {
return new Promise((resolve, reject) => {
let status = statusTools.getStatus();
let option = {
headers: { "Authorization": `Bearer ${token}` },
headers: { "authorization": `Bearer ${token}` },
responseType: "json",
};

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

Expand Down Expand Up @@ -141,7 +141,7 @@ function getSnapshots() {
return new Promise((resolve, reject) => {
let status = statusTools.getStatus();
let option = {
headers: { "Authorization": `Bearer ${token}` },
headers: { "authorization": `Bearer ${token}` },
responseType: "json",
};

Expand Down Expand Up @@ -215,7 +215,7 @@ function dellSnap(id) {
checkSnap(id)
.then(() => {
let option = {
headers: { "Authorization": `Bearer ${token}` },
headers: { "authorization": `Bearer ${token}` },
responseType: "json",
};

Expand All @@ -235,7 +235,7 @@ function dellSnap(id) {
function checkSnap(id) {
return new Promise((resolve, reject) => {
let option = {
headers: { "Authorization": `Bearer ${token}` },
headers: { "authorization": `Bearer ${token}` },
responseType: "json",
};

Expand All @@ -258,7 +258,7 @@ function createNewBackup(name) {
getAddonToBackup().then((addons) => {
let folders = getFolderToBackup();
let option = {
headers: { "Authorization": `Bearer ${token}` },
headers: { "authorization": `Bearer ${token}` },
responseType: "json",
timeout: {
response: create_snap_timeout
Expand Down Expand Up @@ -332,7 +332,7 @@ function uploadSnapshot(path) {

let options = {
body: form,
headers: { "Authorization": `Bearer ${token}` },
headers: { "authorization": `Bearer ${token}` },
};

got.stream
Expand Down Expand Up @@ -386,7 +386,7 @@ function stopAddons() {
statusTools.setStatus(status);
let promises = [];
let option = {
headers: { "Authorization": `Bearer ${token}` },
headers: { "authorization": `Bearer ${token}` },
responseType: "json",
};
let addons_slug = settingsTools.getSettings().auto_stop_addon
Expand Down Expand Up @@ -426,7 +426,7 @@ function startAddons() {
statusTools.setStatus(status);
let promises = [];
let option = {
headers: { "Authorization": `Bearer ${token}` },
headers: { "authorization": `Bearer ${token}` },
responseType: "json",
};
let addons_slug = settingsTools.getSettings().auto_stop_addon
Expand Down Expand Up @@ -473,7 +473,7 @@ function publish_state(state) {


// let option = {
// headers: { "Authorization": `Bearer ${token}` },
// headers: { "authorization": `Bearer ${token}` },
// responseType: "json",
// json: data_error_sensor
// };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,16 @@ class WebdavTools {
statusTools.setStatus(status);
logger.info("Uploading snap...");
let tmpFile = `./temp/${id}.tar`;
let stats = fs.statSync(tmpFile);
let stream = fs.createReadStream(tmpFile);
let conf = this.getConf();
let options = {
body: stream,
// username: this.username,
// password: encodeURIComponent(this.password),
headers: {
'Authorization': 'Basic ' + Buffer.from(this.username + ':' + this.password).toString('base64')
'authorization': 'Basic ' + Buffer.from(this.username + ':' + this.password).toString('base64'),
'content-length': String(stats.size)
}
};
if (conf.ssl === "true") {
Expand Down Expand Up @@ -321,7 +323,7 @@ class WebdavTools {
let conf = this.getConf();
let options = {
headers: {
'Authorization': 'Basic ' + Buffer.from(this.username + ':' + this.password).toString('base64')
'authorization': 'Basic ' + Buffer.from(this.username + ':' + this.password).toString('base64')
}
};
if (conf.ssl === "true") {
Expand Down

0 comments on commit 4622a36

Please sign in to comment.