Only accept application/json requests for (JSON) API requests

This commit is contained in:
Bernd Bestel
2023-09-01 00:53:25 +02:00
parent 8c21969b84
commit 5080d776a7
3 changed files with 12 additions and 6 deletions

View File

@@ -70,7 +70,7 @@ Grocy.Api.Post = function(apiFunction, jsonData, success, error)
};
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-type', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(jsonData));
};
@@ -108,7 +108,7 @@ Grocy.Api.Put = function(apiFunction, jsonData, success, error)
};
xhr.open('PUT', url, true);
xhr.setRequestHeader('Content-type', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(jsonData));
};
@@ -146,7 +146,7 @@ Grocy.Api.Delete = function(apiFunction, jsonData, success, error)
};
xhr.open('DELETE', url, true);
xhr.setRequestHeader('Content-type', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(jsonData));
};
@@ -184,7 +184,7 @@ Grocy.Api.UploadFile = function(file, group, fileName, success, error)
};
xhr.open('PUT', url, true);
xhr.setRequestHeader('Content-type', 'application/octet-stream');
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
xhr.send(file);
};
@@ -222,7 +222,7 @@ Grocy.Api.DeleteFile = function(fileName, group, success, error)
};
xhr.open('DELETE', url, true);
xhr.setRequestHeader('Content-type', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send();
};