Merge pull request #238 from caryoscelus/fix_get_posted_hang

Fix UiServer.getPosted hanging in some circumstances
This commit is contained in:
caryoscelus 2023-11-01 22:47:16 +00:00 committed by GitHub
commit d62d5495ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -231,8 +231,12 @@ class UiRequest(object):
# Return: <dict> Posted variables
def getPosted(self):
if self.env['REQUEST_METHOD'] == "POST":
try:
content_length = int(self.env.get('CONTENT_LENGTH', 0))
except ValueError:
content_length = 0
return dict(urllib.parse.parse_qsl(
self.env['wsgi.input'].readline().decode()
self.env['wsgi.input'].read(content_length).decode()
))
else:
return {}