Switch back to send_file and add a bit of gzip buffering
This commit is contained in:
parent
9344839295
commit
5cca609c55
2 changed files with 15 additions and 10 deletions
|
@ -58,9 +58,6 @@ def get_squashed_tag(namespace, repository, tag, headers):
|
|||
yield current_image_stream
|
||||
|
||||
stream = GzipWrap(StreamLayerMerger(get_next_layer).get_generator())
|
||||
return app.response_class(wrap_file(request.environ, stream, 1024 * 16),
|
||||
mimetype='application/octet-stream',
|
||||
direct_passthrough=True)
|
||||
|
||||
return send_file(stream)
|
||||
|
||||
abort(403)
|
||||
|
|
|
@ -18,13 +18,21 @@ class GzipWrap(object):
|
|||
while True:
|
||||
# Attempt to retrieve the next bytes to write.
|
||||
is_done = False
|
||||
try:
|
||||
s = self.input.next()
|
||||
self.zipper.write(s)
|
||||
except StopIteration:
|
||||
is_done = True
|
||||
|
||||
if len(self.buffer) < size or is_done:
|
||||
input_size = 0
|
||||
input_buffer = ''
|
||||
while input_size < 1024 * 256: # 256K buffer to Gzip
|
||||
try:
|
||||
s = self.input.next()
|
||||
input_buffer += s
|
||||
input_size = input_size + len(s)
|
||||
except StopIteration:
|
||||
is_done = True
|
||||
break
|
||||
|
||||
self.zipper.write(input_buffer)
|
||||
|
||||
if is_done:
|
||||
self.zipper.flush()
|
||||
|
||||
if len(self.buffer) >= size or is_done:
|
||||
|
|
Reference in a new issue