Re: session cookies

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rasmus Lerdorf wrote:
Then you have configured your server to always turn on output
buffering or your test script is bad.

I don't think it's either, but I'll let you decide. I tried a new test with your code and some slight modifications:

<?php

header('Location: http://www.php.net/');
$fp = fopen('/tmp/log.txt', 'w');
for ($i = 0; $i < 30; $i++)
{
    $str = "Count $i\n";
    echo $str;
    fputs($fp, $str);
    sleep(1);
    flush();
}

?>

Basically, I'm only looping 30 times, but I'm sleeping for a second and flushing the buffer each time. The result is a response that looks something like this:

HTTP/1.1 302 Found
Date: Fri, 02 Sep 2005 18:12:02 GMT
Server: Apache/1.3.33 (Debian GNU/Linux)
Location: http://www.php.net/
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

8
Count 0

8
Count 1

8
Count 2

...

9
Count 27

9
Count 28

9
Count 29

0

This result is not buffered on the server by PHP or Apache - each of these chunks are received about one second apart, and the headers are received barely more than one second after the request is sent (only because I didn't flush before the first sleep):

[2005-09-02 14:12:07] [+0.004467 seconds] HTTP Server: socket_read() ...
[2005-09-02 14:12:08] [+1.131124 seconds] > Headers Received
[2005-09-02 14:12:08] [+0.002197 seconds] > Transfer-Encoding [chunked]
[2005-09-02 14:12:08] [+0.004580 seconds] > chunk_length [8]
[2005-09-02 14:12:09] [+1.013278 seconds] > chunk_length [8]
[2005-09-02 14:12:10] [+0.972697 seconds] > chunk_length [8]

Of the three browsers I tested, none sent a request for http://www.php.net/ until they had received the very last byte of the response - the 0 indicating no more content. This happens a little more than 30 seconds after the request is sent and a little more than 29 seconds after the HTTP response line and headers (including Location) are received.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux