Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

readfile_chunked() - do not timeout on slow (dial up) clients, and fl…

…ush buffers explicitly to avoid hogging memory when ob is on
  • Loading branch information...
commit 17729fc82edbf507dee848cc63cab564bf66043b 1 parent 5703ba5
martinlanghoff authored
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/filelib.php
View
13 lib/filelib.php
@@ -367,10 +367,21 @@ function readfile_chunked($filename,$retbytes=true) {
if ($handle === false) {
return false;
}
-
+
+ // don't timeout on slow clients
+ @set_time_limit(0);
+
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
+
+ // write to the client and flush buffers
+ // to avoid hogging memory
echo $buffer;
+ flush();
+ if (ob_get_level() > 0) {
+ ob_flush();
+ }
+
if ($retbytes) {
$cnt += strlen($buffer);}
}
Please sign in to comment.
Something went wrong with that request. Please try again.