buffer flushing not working properly..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TooCrooked
Forum Newbie
Posts: 7
Joined: Fri Oct 27, 2006 6:17 am

buffer flushing not working properly..

Post 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!?!?
printf
Forum Contributor
Posts: 173
Joined: Wed Jan 12, 2005 5:24 pm

Post 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
TooCrooked
Forum Newbie
Posts: 7
Joined: Fri Oct 27, 2006 6:17 am

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If the client doesn't send (or sends different) values for the Accept-Encoding header, the server will likely alter its output.
Post Reply