# HG changeset patch # User RhodeCode Admin # Date 2023-11-24 09:32:00 # Node ID 9410d3a2781ef5994e62c602d4db0e9e9435baf9 # Parent 76dbde25f3e8bf812543a0e0cacfd321cb7c8323 fix(svn): fix the problems of reading txn_id when used gunicorn/waitress + traefik/no-traefik combinations diff --git a/rhodecode/lib/middleware/simplevcs.py b/rhodecode/lib/middleware/simplevcs.py --- a/rhodecode/lib/middleware/simplevcs.py +++ b/rhodecode/lib/middleware/simplevcs.py @@ -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(