20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
regex_start_range = re.compile('\d+(?=\-)')
regex_stop_range = re.compile('(?<=\-)\d+')
DEFAULT_CHUNK_SIZE = 64*1024
def streamer(stream, chunk_size = DEFAULT_CHUNK_SIZE, bytes = None):
offset = 0
while bytes == None or offset < bytes:
if bytes != None and bytes - offset < chunk_size:
chunk_size = bytes - offset
data = stream.read(chunk_size)
length = len(data)
if not length:
break
else:
yield data
|
|
|
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
regex_start_range = re.compile('\d+(?=\-)')
regex_stop_range = re.compile('(?<=\-)\d+')
DEFAULT_CHUNK_SIZE = 64*1024
def streamer(stream, chunk_size = DEFAULT_CHUNK_SIZE, bytes = None):
offset = 0
while bytes is None or offset < bytes:
if not bytes is None and bytes - offset < chunk_size:
chunk_size = bytes - offset
data = stream.read(chunk_size)
length = len(data)
if not length:
break
else:
yield data
|
102
103
104
105
106
107
108
109
|
bytes = None
status = 200
if request and request.env.web2py_use_wsgi_file_wrapper:
wrapped = request.env.wsgi_file_wrapper(stream, chunk_size)
else:
wrapped = streamer(stream, chunk_size=chunk_size, bytes=bytes)
raise HTTP(status, wrapped, **headers)
|
>
>
|
102
103
104
105
106
107
108
109
110
111
|
bytes = None
status = 200
if request and request.env.web2py_use_wsgi_file_wrapper:
wrapped = request.env.wsgi_file_wrapper(stream, chunk_size)
else:
wrapped = streamer(stream, chunk_size=chunk_size, bytes=bytes)
raise HTTP(status, wrapped, **headers)
|