summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorBrian Waldon <brian.waldon@rackspace.com>2011-07-08 17:40:56 -0400
committerBrian Waldon <brian.waldon@rackspace.com>2011-07-08 17:40:56 -0400
commitb5ca0d793826ac10ee41be84f18d64b09113aa80 (patch)
tree4eef130b2d023048fe31a850f0cdd6609c93e9b3 /nova/api
parentfe8da67779dbb03654b1cce90eeafdb323507673 (diff)
downloadnova-b5ca0d793826ac10ee41be84f18d64b09113aa80.tar.gz
nova-b5ca0d793826ac10ee41be84f18d64b09113aa80.tar.xz
nova-b5ca0d793826ac10ee41be84f18d64b09113aa80.zip
refactor
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/wsgi.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
index bd91aed60..7a8376722 100644
--- a/nova/api/openstack/wsgi.py
+++ b/nova/api/openstack/wsgi.py
@@ -52,9 +52,9 @@ class Request(webob.Request):
content_type = self.content_type
if content_type not in allowed_types:
- return None
- else:
- return content_type
+ raise exception.InvalidContentType(content_type=content_type)
+
+ return content_type
class TextDeserializer(object):
@@ -171,19 +171,22 @@ class RequestDeserializer(object):
def deserialize_body(self, request, action):
try:
content_type = request.get_content_type()
+ except exception.InvalidContentType:
+ LOG.debug(_("Unrecognized Content-Type provided in request"))
+ return {}
- if content_type is None:
- LOG.debug(_("No Content-Type provided in request"))
- return {}
+ if content_type is None:
+ LOG.debug(_("No Content-Type provided in request"))
+ return {}
- if not len(request.body) > 0:
- LOG.debug(_("Empty body provided in request"))
- return {}
+ if not len(request.body) > 0:
+ LOG.debug(_("Empty body provided in request"))
+ return {}
+ try:
deserializer = self.get_body_deserializer(content_type)
-
except exception.InvalidContentType:
- LOG.debug(_("Unable to read body as provided Content-Type"))
+ LOG.debug(_("Unable to deserialize body as provided Content-Type"))
raise
return deserializer.deserialize(request.body, action)