From c92b8bc56c796a962baec69f42072433c65bb3b7 Mon Sep 17 00:00:00 2001 From: caryoscelus Date: Wed, 1 Nov 2023 22:12:14 +0000 Subject: [PATCH] Fix UiServer.getPosted hanging in some circumstances fixes #198 while it's not exactly clear what causes the difference in behaviour, but under certain conditions UiServer.getPosted used to hang trying to readline() POST request (e.g. from UiPassword login). using read(CONTENT_LENGTH) seems to fix the issue --- src/Ui/UiRequest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Ui/UiRequest.py b/src/Ui/UiRequest.py index b5d1736e..0f8437d6 100644 --- a/src/Ui/UiRequest.py +++ b/src/Ui/UiRequest.py @@ -231,8 +231,12 @@ class UiRequest(object): # Return: 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 {}