|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-02-20 12:10 UTC] unreal at slashorg dot net
Description:
------------
PHP doesn't handle browser abort correctly.
- Use PHP to serve a file, using the code below
- Start downloading the file, and then abort.
Reproduce code:
---------------
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: public');
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header('Content-Disposition: attachment; filename="' . basename($path) . '";');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($path));
$handle = fopen($path, 'rb');
do {
$data = fread($handle, 8192);
if (strlen($data) == 0) {
break;
}
echo($data);
} while (true);
fclose($handle);
Expected result:
----------------
After browser abord, the server should remain responsive.
Actual result:
--------------
* Lots of errors in error_log:
'FastCGI: comm with server "/usr/local/www/cgi/php-cgi/php5.fcgi" aborted: idle timeout (30 sec)'
'FastCGI: incomplete headers (0 bytes) received from server "/usr/local/www/cgi/php-cgi/php5.fcgi"'
* Server stops responding, then after some time (maybe 5 mins), starts responding again.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 18:00:02 2025 UTC |
I am not able to reproduce the problem. I tried to abort downloading from IE and download part of file running the following PHP script from command line: <?php $f = fopen("http://127.0.0.1/test/bug40556.php", "r"); $s = fread($f, 1024*1024); var_dump($s); fclose($f); ?> both cases work fine (Apache-1.3.28 with mod_fastcgi or ZendEnabler on Linux 2.6.19)OK, I've done quite a lot more testing, and here are the results (Apache 2.0.59/mod_fastcgi 2.4.2/PHP 5.2.1): - I cannot reproduce the bug with your code either. - The following code causes PHP workers to lock up if you abort during download (and only if you abort): http://www.slashorg.net/ex/crash.txt Note: notice the "session_start();" line - If I remove the "session_start();" line, PHP doesn't crash anymore, even when I abort the download. It seems this bug is more complicated than I thought, I hope you'll be able to reproduce it. Thanks for your help.