From 3aa41ec7b1ab36b2c9065649cc1212805e499a55 Mon Sep 17 00:00:00 2001 From: Christophe de Vienne Date: Wed, 11 Jul 2012 17:10:20 +0200 Subject: [PATCH] Use request.content_lenght to check for a request.body existence before accessing it --- wsme/root.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wsme/root.py b/wsme/root.py index d37e948..9faca51 100644 --- a/wsme/root.py +++ b/wsme/root.py @@ -130,9 +130,11 @@ class WSRoot(object): def _select_protocol(self, request): log.debug("Selecting a protocol for the following request :\n" "headers: %s\nbody: %s", request.headers, - request.body and (len(request.body) > 512 - and request.body[:512] - or request.body) or '') + request.content_length and ( + request.content_length > 512 + and request.body[:512] + or request.body) + or '') protocol = None if 'wsmeproto' in request.params: return self._get_protocol(request.params['wsmeproto'])