ID:               32512
 User updated by:  kulakov74 at yandex dot ru
 Reported By:      kulakov74 at yandex dot ru
 Status:           Bogus
 Bug Type:         Output Control
 Operating System: Linux, Win 2000
 PHP Version:      4.3.9
 New Comment:

Yes, sorry again - it was my fault and the bug should be closed /
deleted. As for register_shutdown_function(), I checked the updated
documentation and found I was wrong too - connection should be opened.


Previous Comments:
------------------------------------------------------------------------

[2005-04-01 10:40:28] [EMAIL PROTECTED]

But no bug in flush...


------------------------------------------------------------------------

[2005-04-01 09:53:55] kulakov74 at yandex dot ru

I'm sorry, this is my fault - the HTTP-interface I use for testing
could not display single characters which made me think PHP didn't send
anything. After I added newlines to the output - echo("-\n"); flush(); -
it worked as expected. 

Also, I tried using register_shutdown_function to separate the slow
part from sending headers, but it didn't work. The docs says:

The registered shutdown functions are called after the request has been
completed (including sending any output buffers), so it is not possible
to send output to the browser using echo() or print()...

But I tried to output with echo() within the regisreted function and,
to my surprise, the output got to the browser! Seems like when the
function is called the connection may well be open unless it was closed
by the user/net; I wish there would be a way to tell Apache to close it
at any moment so that script would run in background.

------------------------------------------------------------------------

[2005-03-31 22:00:43] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

I can NOT reproduce this with latest CVS (tested PHP_4_3 / HEAD
branches)

------------------------------------------------------------------------

[2005-03-31 10:32:10] kulakov74 at yandex dot ru

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 this bug report at http://bugs.php.net/?id=32512&edit=1

Reply via email to