http-app: simplify detection of chunked encoding.

- since we now properly use chunked requests git client reports this in nicer way.
we no longer need to rely on hacks to detect chunked streams.
This commit is contained in:
Marcin Kuzminski 2017-04-18 09:31:49 +02:00
parent a7a1af8449
commit 479c786358

View file

@ -126,6 +126,11 @@ class VcsHttpProxy(object):
return _maybe_stream_response(response)
def _is_request_chunked(environ):
stream = environ.get('HTTP_TRANSFER_ENCODING', '') == 'chunked'
return stream
def _maybe_stream_request(environ):
path = environ['PATH_INFO']
stream = _is_request_chunked(environ)
@ -137,15 +142,6 @@ def _maybe_stream_request(environ):
return environ['wsgi.input'].read()
def _is_request_chunked(environ):
stream = environ.get('HTTP_TRANSFER_ENCODING', '') == 'chunked'
if not stream:
# git lfs should stream for PUT requests which are upload
stream = ('git-lfs' in environ.get('HTTP_USER_AGENT', '')
and environ['REQUEST_METHOD'] == 'PUT')
return stream
def _maybe_stream_response(response):
"""
Try to generate chunks from the response if it is chunked.