Patched POST API bug

It is no longer possible to make a POST request with no body content and make a "ghost key" - which upon requesting returns 404, but it considered as a taken key
This commit is contained in:
zneix 2020-09-02 16:18:47 +02:00
parent 7de68695fe
commit 04e1f09fed
No known key found for this signature in database
GPG Key ID: 911916E0523B22F6
1 changed files with 6 additions and 0 deletions

View File

@ -80,6 +80,12 @@ DocumentHandler.prototype.handlePost = function (req, res){
let onSuccess = async function (){
//check length
if (!buffer.length){
cancelled = true;
winston.warn('document with no length was POSTed');
res.status(411).json({ message: 'Length required.' });
return;
}
if (_this.maxLength && buffer.length > _this.maxLength){
cancelled = true;
winston.warn('document >maxLength', { maxLength: _this.maxLength });