def req_yaml(self, req):
if req.content_length is None or req.content_length == 0:
return None
raw_body = req.stream.read(req.content_length or 0)
if raw_body is None:
return None
try:
return yaml.safe_load_all(raw_body.decode('utf-8'))
except yaml.YAMLError as jex:
self.error(
req.context,
"Invalid YAML in request: \n%s" % raw_body.decode('utf-8'))
raise Exception(
"%s: Invalid YAML in body: %s" % (req.path, jex))
评论列表
文章目录