Workaround Python 3.x CGI bug which causes #2262

Obviously the client also needs to send a Content-Disposition header for this to work
This commit is contained in:
Fran Boon
2020-04-13 16:57:36 +01:00
committed by GitHub
parent 405b0b2e68
commit 5490480906
+9 -1
View File
@@ -242,7 +242,15 @@ class Request(Storage):
# parse POST variables on POST, PUT, BOTH only in post_vars
if body and not is_json and env.request_method in ('POST', 'PUT', 'DELETE', 'BOTH'):
query_string = env.pop('QUERY_STRING', None)
dpost = cgi.FieldStorage(fp=body, environ=env, keep_blank_values=1)
content_disposition = env.get('HTTP_CONTENT_DISPOSITION')
if content_disposition:
headers = {'content-disposition': content_disposition,
'content-type': env['CONTENT_TYPE'],
'content-length': env['CONTENT_LENGTH'],
}
else:
headers = None
dpost = cgi.FieldStorage(fp=body, environ=env, headers=headers, keep_blank_values=1)
try:
post_vars.update(dpost)
except: