##// END OF EJS Templates
git-lfs: streaming support for file upload....
marcink -
r1566:63143d9d default
parent child Browse files
Show More
@@ -127,17 +127,32 b' class VcsHttpProxy(object):'
127 127
128 128
129 129 def _maybe_stream_request(environ):
130 if environ.get('HTTP_TRANSFER_ENCODING', '') == 'chunked':
130 path = environ['PATH_INFO']
131 stream = _is_request_chunked(environ)
132 log.debug('handling request `%s` with stream support: %s', path, stream)
133
134 if stream:
131 135 return environ['wsgi.input']
132 136 else:
133 137 return environ['wsgi.input'].read()
134 138
135 139
140 def _is_request_chunked(environ):
141 stream = environ.get('HTTP_TRANSFER_ENCODING', '') == 'chunked'
142 if not stream:
143 # git lfs should stream for PUT requests which are upload
144 stream = ('git-lfs' in environ.get('HTTP_USER_AGENT', '')
145 and environ['REQUEST_METHOD'] == 'PUT')
146 return stream
147
148
136 149 def _maybe_stream_response(response):
137 150 """
138 151 Try to generate chunks from the response if it is chunked.
139 152 """
140 if _is_chunked(response):
153 stream = _is_chunked(response)
154 log.debug('returning response with stream: %s', stream)
155 if stream:
141 156 return response.raw.read_chunked()
142 157 else:
143 158 return [response.content]
@@ -207,6 +207,8 b' def http_environ(http_host_stub):'
207 207 'SERVER_NAME': http_host_stub.split(':')[0],
208 208 'SERVER_PORT': http_host_stub.split(':')[1],
209 209 'HTTP_HOST': http_host_stub,
210 'HTTP_USER_AGENT': 'rc-test-agent',
211 'REQUEST_METHOD': 'GET'
210 212 }
211 213
212 214
General Comments 0
You need to be logged in to leave comments. Login now