Switch back to send_file and add a bit of gzip buffering

This commit is contained in:
Joseph Schorr 2014-09-16 14:20:42 -04:00
parent 9344839295
commit 5cca609c55
2 changed files with 15 additions and 10 deletions

View file

@ -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: