From 04e1f09fedbaa9a83a6d747f033467e1f42f4d53 Mon Sep 17 00:00:00 2001 From: zneix <44851575+zneix@users.noreply.github.com> Date: Wed, 2 Sep 2020 16:18:47 +0200 Subject: [PATCH] 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 --- lib/document_handler.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/document_handler.js b/lib/document_handler.js index c6ba21d..78ae674 100644 --- a/lib/document_handler.js +++ b/lib/document_handler.js @@ -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 });