Page 1 of 1

buffer flushing not working properly..

Posted: Fri Oct 27, 2006 6:23 am
by TooCrooked
my web host (http://toocrooked.goldeye.info/) uses PHP version 4.3.4

my home server uses 4.4.2

my home server allows me to flush() the buffer as often as i want, and it works beautifully.

however, the web host completely ignores my flush() requests... what are possible reasons for this? my link above has a file called "test.php" which contains the following code:

Code: Select all

<HTML>
<BODY>
<DIV ID="flushme">
Hello, world!
</DIV>
<?php flush(); sleep(2); ?>
<SCRIPT>
d = document.getElementById("flushme");
d.innerHTML = "Goodbye, Perl!";
</SCRIPT>
<?php flush(); sleep(2); ?>
<SCRIPT>
d.innerHTML = "Goodnight, New York!";
</SCRIPT>
</BODY>
</HTML>
on my home computer, this shows properly.. hello, pause, goodbye, pause, goodnight.. however, my web host sees only the last line...

why would this occur?? what has my web host done to me!?!?

Posted: Fri Oct 27, 2006 9:28 am
by printf
The server is using GZIP compression, so the buffer will be held until the compression buffer is filled! You can try sending a Status header and add ob_flush(); before you call flush();, but it will mostly not work, if the server is compressing output!

Code: Select all

Socket Class 2.04

http://toocrooked.goldeye.info/version.php

execution time = 0.08460822105408 (seconds)

Request Header:

GET /version.php HTTP/1.0
Host: toocrooked.goldeye.info
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204
Referer: http://toocrooked.goldeye.info/version.php
Accept-Language: en-us, en;q=0.50
Accept-Encoding: gzip, deflate, compress;q=0.9
Connection: Close


Response Header:

HTTP/1.1 200 OK
Date: Fri, 27 Oct 2006 14:20:52 GMT
Server: Apache/1.3.33 (Unix) mod_ssl/2.8.22 OpenSSL/0.9.7d VDB/1.1.1-se
X-Powered-By: PHP/4.3.4
Content-Encoding: gzip
Content-Length: 7562
Connection: close
Content-Type: text/html

printf

Posted: Fri Oct 27, 2006 12:28 pm
by TooCrooked
Oy Gevalt! great info! thanks for such a quick, accurate response (:

is it possible to tell the client to tell the server that it CANNOT handle a compressed page so that it responds correctly?

Posted: Fri Oct 27, 2006 1:30 pm
by feyd
If the client doesn't send (or sends different) values for the Accept-Encoding header, the server will likely alter its output.