def load_body(self):
""" Load http request body and returns
form data and files.
"""
environ = self.environ
cl = environ['CONTENT_LENGTH']
icl = int(cl)
if icl > self.max_content_lenght:
raise ValueError('Maximum content length exceeded')
fp = environ['wsgi.input']
ct = environ['CONTENT_TYPE']
# application/x-www-form-urlencoded
if '/x' in ct:
return parse_qs(fp.read(icl).decode(self.encoding)), None
# application/json
elif '/j' in ct:
return json_loads(fp.read(icl).decode(self.encoding)), None
# multipart/form-data
elif ct.startswith('m'):
return parse_multipart(fp, ct, cl, self.encoding)
else:
return None, None
评论列表
文章目录