http-proto: in case incoming requests come in as chunked stream the data to VCSServer.

This should solve a problem of uploading large files to rhodecode. In case of
git with small postBuffers GIT client streams data to the server. In such
case we want to stream the data back again to vcsserver without reading it fully
inside RhodeCode.
This commit is contained in:
Marcin Kuzminski 2017-02-10 16:25:06 +01:00
parent 332dcebbbf
commit 1f542f99c0

View file

@ -93,7 +93,6 @@ class VcsHttpProxy(object):
'X-RC-Locked-Status-Code': rhodecode.CONFIG.get('lock_ret_code')
})
data = environ['wsgi.input'].read()
method = environ['REQUEST_METHOD']
# Preserve the query string
@ -104,7 +103,7 @@ class VcsHttpProxy(object):
response = session.request(
method, url,
data=data,
data=_maybe_stream_request(environ),
headers=request_headers,
stream=True)
@ -120,10 +119,17 @@ class VcsHttpProxy(object):
reason_phrase=response.reason)
start_response(status, response_headers)
return _maybe_stream(response)
return _maybe_stream_response(response)
def _maybe_stream(response):
def _maybe_stream_request(environ):
if environ.get('HTTP_TRANSFER_ENCODING', '') == 'chunked':
return environ['wsgi.input']
else:
return environ['wsgi.input'].read()
def _maybe_stream_response(response):
"""
Try to generate chunks from the response if it is chunked.
"""