user1750728 user1750728 - 5 months ago 16x
Perl Question

ubuntu apache2 cgi output buffering

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";

print "hi..";
sleep 1;
print "hi..";
sleep 1;
print "hi..";
sleep 1;

I have verified that mod_deflate is disabled.

Also, it's NOT just a perl thing, the same cgi script written in bash behaves the same on ubuntu VS centos/rhel.

I'm going crazy here, surely someone has ran into this before...

Thanks !


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:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

Explorer however still seems to wait for all data before rendering the page, other browsers I do not have available.