]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fixing check order for empty body in get_body()
authorAndres Buraschi <andres.buraschi@intel.com>
Thu, 28 Nov 2013 14:35:07 +0000 (11:35 -0300)
committerAndres Buraschi <andres.buraschi@intel.com>
Thu, 28 Nov 2013 14:41:39 +0000 (11:41 -0300)
Cinder API logged the following debug message for each request with
empty body:
"Unrecognized Content-Type provided in request get_body"
Check order was fixed in get_body function to follow the correct flow
and display the right message (empty body).

Change-Id: Ie561983a4da791a412fea3fc390dab718dfce191
Closes-Bug: #1252692

cinder/api/openstack/wsgi.py

index d2eee19cfe8f5c5891fb30b4fff8b2e9156235a3..70d127e81361dea34a1aa42f4e1d246763d8e983 100644 (file)
@@ -790,6 +790,11 @@ class Resource(wsgi.Application):
         return args
 
     def get_body(self, request):
+
+        if len(request.body) == 0:
+            LOG.debug(_("Empty body provided in request"))
+            return None, ''
+
         try:
             content_type = request.get_content_type()
         except exception.InvalidContentType:
@@ -800,10 +805,6 @@ class Resource(wsgi.Application):
             LOG.debug(_("No Content-Type provided in request"))
             return None, ''
 
-        if len(request.body) <= 0:
-            LOG.debug(_("Empty body provided in request"))
-            return None, ''
-
         return content_type, request.body
 
     def deserialize(self, meth, content_type, body):