summaryrefslogtreecommitdiff
path: root/apifw/bottleapp.py
diff options
context:
space:
mode:
Diffstat (limited to 'apifw/bottleapp.py')
-rw-r--r--apifw/bottleapp.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/apifw/bottleapp.py b/apifw/bottleapp.py
index 774e1c2..541ddfe 100644
--- a/apifw/bottleapp.py
+++ b/apifw/bottleapp.py
@@ -258,9 +258,15 @@ class BottleApplication:
return wrapper
def _get_request_body(self):
+ raw_body = bottle.request.body.read()
+ if bottle.request.method in ('POST', 'PUT'):
+ if len(raw_body) == 0:
+ raise bottle.HTTPError(
+ apifw.HTTP_LENGTH_REQUIRED,
+ body='Empty body not allowed for PUT/POST')
+
json_type = 'application/json'
content_type = bottle.request.get_header('Content-Type')
- raw_body = bottle.request.body.read()
if content_type != json_type:
return content_type, raw_body