I'm having problems with apache2 on unbuntu ( 11.04 and 12.04 ) buffering all cgi output until the script terminates. If I run the same script on Centos/rhel 6.2 apache2, it runs normally.
print "Content-type: text/html\r\n\r\n";
I encountered a similar problem on Solaris 10, but found out, that is was actually not a problem of apache but instead of the web browser (firefox 15.0.1).
(I could verify this with
telnet webserver 80 and speaking plain HTML, the response showed that the output was indeed not buffered)
I could solve this for firefox by also printing a header with a Content-Type meta tag:
print<<'_EOF_'; <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> _EOF_
Explorer however still seems to wait for all data before rendering the page, other browsers I do not have available.