From: kulakov74 at yandex dot ru
Operating system: Linux, Win 2000
PHP version: 4.3.9
PHP Bug Type: Output Control
Bug description: flush() does not work after sending Location header
Description:
------------
We want a script to make a redirect and then make some Sql-queries, so
that the user would not wait for the queries to execute (sometimes they
may take too long). I added
echo("-"); flush();
after sending the Location header which made PHP send the header
immediately away, but the problem is IE does not make the redirect as soon
as it gets the header - probably it expects other headers or a page, so it
only redirects after the script completes. If I add more output after that
and a flush() call then PHP won't output anything else until the script
completes. This is emulated with a sleep(3) call. More precisely, PHP only
sends headers immediately, it doesn't send anything else (the dash in this
case).
Reproduce code:
---------------
//This is the redirect
header("Location: http://hotelsys.biz/hotels/Bali");
//This is how I force PHP to send it right away
echo("-"); flush();
//This is how I cannot make PHP send anything else
echo(str_repeat("-", 1024*16)); flush();
//Pause emulation
sleep(3);
//the end - this is when the browser gets the output
exit;
Expected result:
----------------
The first "-" character and the next 16K of it sent right away.
Actual result:
--------------
I only get dashes in 3 seconds; the browser (IE) makes the redirect in
this time too.
--
Edit bug report at http://bugs.php.net/?id=32512&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32512&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=32512&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=32512&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32512&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32512&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32512&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32512&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32512&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32512&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32512&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=32512&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=32512&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32512&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32512&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32512&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32512&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32512&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32512&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32512&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32512&r=mysqlcfg