# HG changeset patch # User Johannes Bornhold # Date 2016-06-21 15:12:28 # Node ID 5d91eb8d64e238590427691d741c2b0a17976d2e # Parent 53bb81e90eb61d5302c96982eafda0eb9183fccb svn: Avoid chunked transfer for Subversion diff --git a/rhodecode/lib/middleware/simplesvn.py b/rhodecode/lib/middleware/simplesvn.py --- a/rhodecode/lib/middleware/simplesvn.py +++ b/rhodecode/lib/middleware/simplesvn.py @@ -39,10 +39,10 @@ class SimpleSvnApp(object): request_headers = self._get_request_headers(environ) data = environ['wsgi.input'] - # johbo: On Gunicorn, we end up with a 415 response if we pass data - # to requests. I think the request is usually without payload, still - # reading the data to be on the safe side. - if environ['REQUEST_METHOD'] == 'MKCOL': + # johbo: Avoid that we end up with sending the request in chunked + # transfer encoding (mainly on Gunicorn). If we know the content + # length, then we should transfer the payload in one request. + if environ['REQUEST_METHOD'] == 'MKCOL' or 'CONTENT_LENGTH' in environ: data = data.read() response = requests.request( diff --git a/rhodecode/tests/lib/middleware/test_simplesvn.py b/rhodecode/tests/lib/middleware/test_simplesvn.py --- a/rhodecode/tests/lib/middleware/test_simplesvn.py +++ b/rhodecode/tests/lib/middleware/test_simplesvn.py @@ -178,7 +178,7 @@ class TestSimpleSvnApp(object): ] request_mock.assert_called_once_with( self.environment['REQUEST_METHOD'], expected_url, - data=self.wsgi_input, headers=expected_request_headers) + data=self.data, headers=expected_request_headers) response_mock.iter_content.assert_called_once_with(chunk_size=1024) args, _ = start_response.call_args assert args[0] == '200 OK'