Commit 3dde1b45 authored by Nigel McNie's avatar Nigel McNie

(#3359) Prevent readfile_chunked() and byteserving_send_file() timing out on slow connections.

Patch supplied by Iñaki Arenaza.
Signed-off-by: default avatarNigel McNie <nigel@catalyst.net.nz>
(cherry picked from commit cf6bcdf0)
parent bc1073ab
......@@ -192,9 +192,9 @@ function readfile_chunked($filename, $retbytes=true) {
return false;
}
@set_time_limit(60 * 60); //reset time limit to 60 min - should be enough for 1 MB chunk
while (!feof($handle)) {
@set_time_limit(60 * 60); //reset time limit to 60 min - should be enough for 1 MB chunk
$buffer = fread($handle, $chunksize);
echo $buffer;
flush();
......@@ -225,10 +225,10 @@ function byteserving_send_file($filename, $mimetype, $ranges) {
header('Content-Range: bytes ' . $ranges[0][1] . '-' . $ranges[0][2] . '/' . filesize($filename));
header('Content-Type: ' . $mimetype);
while (@ob_end_flush()); //flush the buffers - save memory and disable sid rewrite
@set_time_limit(60*60); //reset time limit to 60 min - should be enough for 1 MB chunk
$buffer = '';
fseek($handle, $ranges[0][1]);
while (!feof($handle) && $length > 0) {
@set_time_limit(60*60); //reset time limit to 60 min - should be enough for 1 MB chunk
$buffer = fread($handle, ($chunksize < $length ? $chunksize : $length));
echo $buffer;
flush();
......@@ -253,8 +253,8 @@ function byteserving_send_file($filename, $mimetype, $ranges) {
echo $range[0];
$buffer = '';
fseek($handle, $range[1]);
@set_time_limit(60 * 60); //reset time limit to 60 min - should be enough for 1 MB chunk
while (!feof($handle) && $length > 0) {
@set_time_limit(60 * 60); //reset time limit to 60 min - should be enough for 1 MB chunk
$buffer = fread($handle, ($chunksize < $length ? $chunksize : $length));
echo $buffer;
flush();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment