final fix for "Network error" when stream files to client

It is important to FIRST disable zlib.output_compression (before headers are sent!) and THEN end all output-buffering!
Without the two steps in this order, we are either limited by the memory limit or get the "Network error", because the streaming/fpassthrough does not apply the compression.
This commit is contained in:
ralf 2022-05-05 12:47:31 +02:00
parent db07f6bb71
commit 8d645e5a7d
3 changed files with 17 additions and 3 deletions

View File

@ -1504,6 +1504,11 @@ class Vfs extends Vfs\Base
//error_log("Total files: " . $total_files . " Peak memory to zip: " . self::hsize(memory_get_peak_usage(true)));
// FIRST: switch off zlib.output_compression, as this would limit downloads in size to memory_limit
ini_set('zlib.output_compression',0);
// SECOND: end all active output buffering
while(ob_end_clean()) {}
// Stream the file to the client
header("Content-Type: application/zip");
header("Content-Length: " . filesize($zip_file));

View File

@ -446,6 +446,11 @@ class importexport_export_ui {
$appname = $_GET['_appname'];
$nicefname = $_GET['filename'] ? $_GET['filename'] : 'egw_export_'.$appname.'-'.date('Y-m-d');
// FIRST: switch off zlib.output_compression, as this would limit downloads in size to memory_limit
ini_set('zlib.output_compression',0);
// SECOND: end all active output buffering
while(ob_end_clean()) {}
// Get charset
$charset = Api\Cache::getSession('importexport', $tmpfname);

View File

@ -42,8 +42,12 @@ if (!empty($_POST['download']))
{
$file = key($_POST['download']);
$file = $db_backup->backup_dir.'/'.basename($file); // basename to now allow to change the dir
while (@ob_end_clean()) {} // end all active output buffering
ini_set('zlib.output_compression',0); // switch off zlib.output_compression, as this would limit downloads in size to memory_limit
// FIRST: switch off zlib.output_compression, as this would limit downloads in size to memory_limit
ini_set('zlib.output_compression',0);
// SECOND: end all active output buffering
while(ob_end_clean()) {}
Api\Header\Content::type(basename($file));
readfile($file);
exit;