From ba9ea2863cb7ef52b8be7f3b9cd73869023d24ba Mon Sep 17 00:00:00 2001 From: Timo Puschkasch Date: Fri, 1 Jul 2016 14:22:55 +0200 Subject: [PATCH] Failing on empty body is intended for non-GET requests See corresponding test cases for details and reasoning --- flask/wrappers.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/flask/wrappers.py b/flask/wrappers.py index a8b05a09..bb224681 100644 --- a/flask/wrappers.py +++ b/flask/wrappers.py @@ -151,12 +151,11 @@ class Request(RequestBase): try: data = _get_data(self, cache) - if not data and not force: + if self.method == 'GET' and not data and not force: # Some clients will send a MIME-type of "application/json" - # with an empty message body by default, even on empty - # get requests. This behaviour can cause loading to fail - # with a ValueError although RFC2616 does not explicitly - # forbid such requests. + # with an empty message body on empty get requests. + # This can cause loading to fail with a ValueError + # although RFC2616 does not explicitly forbid such requests. rv = None elif request_charset is not None: rv = json.loads(data, encoding=request_charset)