Parsed_body now raises ValueError if it can't find a parser.
This commit is contained in:
@@ -369,10 +369,15 @@ class Request(object):
|
|||||||
if not hasattr(self, '_cached_parsed_body'):
|
if not hasattr(self, '_cached_parsed_body'):
|
||||||
body = self.read_body()
|
body = self.read_body()
|
||||||
if hasattr(self.site, 'parsers'):
|
if hasattr(self.site, 'parsers'):
|
||||||
parser = self.site.parsers.get(
|
ct = self.get_header('content-type')
|
||||||
self.get_header('content-type'))
|
parser = self.site.parsers.get(ct)
|
||||||
|
|
||||||
if parser is not None:
|
if parser is not None:
|
||||||
body = parser(body)
|
body = parser(body)
|
||||||
|
else:
|
||||||
|
ex = ValueError("Could not find parser for content-type: %s" % ct)
|
||||||
|
ex.body = body
|
||||||
|
raise ex
|
||||||
self._cached_parsed_body = body
|
self._cached_parsed_body = body
|
||||||
return self._cached_parsed_body
|
return self._cached_parsed_body
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user