Use request.content_lenght to check for a request.body existence before accessing it

This commit is contained in:
Christophe de Vienne 2012-07-11 17:10:20 +02:00
parent 92f1e76014
commit 3aa41ec7b1

View File

@ -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'])