Skip to content

Commit c92b8bc

Browse files
committed
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
1 parent 19056b4 commit c92b8bc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/Ui/UiRequest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,12 @@ def getContentType(self, file_name):
231231
# Return: <dict> Posted variables
232232
def getPosted(self):
233233
if self.env['REQUEST_METHOD'] == "POST":
234+
try:
235+
content_length = int(self.env.get('CONTENT_LENGTH', 0))
236+
except ValueError:
237+
content_length = 0
234238
return dict(urllib.parse.parse_qsl(
235-
self.env['wsgi.input'].readline().decode()
239+
self.env['wsgi.input'].read(content_length).decode()
236240
))
237241
else:
238242
return {}

0 commit comments

Comments
 (0)