php - IFrame Comet response contains no data -
i'm experimenting comet , i'm stuck implementing via hidden iframe ("forever frame".
this index.html:
<!doctype html> <html> <head> <script type="text/javascript"> cometresponse = function() { var debugout = document.getelementbyid('debugoutput'); return function(response) { debugout.innerhtml = response.number; } } </script> </head> <body> <div id="debugoutput"></div> <iframe src="comet.php"></iframe> </body> </html>
and comet.php file:
<?php set_time_limit(0); header('content-type: text/html'); header('cache-control: no-cache, must-revalidate'); header('expires: mon, 26 jul 1997 05:00:00 gmt'); header('transfer-encoding: chunked'); flush(); ob_flush(); $response = '<script type="text/javascript"> parent.cometresponse({ number: %1$d }); </script>'; ($i = 0; $i < 2; $i++) { sleep(1); $data = sprintf($response, $i); $output = strtoupper(dechex(strlen($data)))."\r\n".$data."\r\n"; echo $output; flush(); ob_flush(); } echo "0\r\n\r\n";
after loading page, browser seems "wait" response. after few seconds, firebug shows empty response these response headers:
http/1.1 200 ok date: mon, 26 jul 2010 09:34:04 gmt server: apache/2.2.14 (win32) php/5.2.12 x-powered-by: php/5.2.12 cache-control: no-cache, must-revalidate expires: mon, 26 jul 1997 05:00:00 gmt transfer-encoding: chunked vary: accept-encoding content-encoding: gzip keep-alive: timeout=5, max=99 connection: keep-alive content-type: text/html;charset=iso-8859-2
since response treated empty, tag should in response doesn't executed either.
however, if remove "transfer-encoding: chunked" header, content sent browser correctly in 1 big piece @ end of script, expected.
i can't find what's going wrong here.
two guesses:
content-encoding: gzip
maybe mod_gzip not work correctly? have tried on annother host?
- maybe firefox ignores code, if not within < html>
Comments
Post a Comment