fix(svn): fix the problems of reading txn_id when used gunicorn/waitress + traefik/no-traefik combinations

This commit is contained in:
RhodeCode Admin 2023-11-24 10:32:00 +01:00
parent 234a3dd25f
commit 2033612a4e

View file

@ -605,7 +605,18 @@ class SimpleVCS(object):
# case for SVN, we want to re-use the callback daemon port
# so we use the txn_id, for this we peek the body, and still save
# it as wsgi.input
data: str = safe_str(environ['wsgi.input'].getvalue())
stream = environ['wsgi.input']
if isinstance(stream, io.BytesIO):
data: str = safe_str(stream.getvalue())
elif hasattr(stream, 'buf'): # most likely gunicorn.http.body.Body
data: str = safe_str(stream.buf.getvalue())
else:
# fallback to the crudest way, copy the iterator
data = safe_str(stream.read())
environ['wsgi.input'] = io.BytesIO(safe_bytes(data))
txn_id = extract_svn_txn_id(self.acl_repo_name, data)
callback_daemon, extras = self._prepare_callback_daemon(