Ubuntu apache2 cgi output buffering

I am having problems with apache2 on unbuntu (11.04 and 12.04), buffering all cgi output until the script completes. If I run the same script on Centos / rhel 6.2 apache2, it works fine.

#!/usr/bin/perl $|=1; print "Content-type: text/html\r\n\r\n"; print "hi.."; sleep 1; print "hi.."; sleep 1; print "hi.."; sleep 1; 

I checked that mod_deflate is disabled.

In addition, this is 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, for sure someone has come across this before ...

Thanks!

+4
source share
3 answers

I ran into a similar problem on Solaris 10, but found out that this is actually not an Apache problem, but instead of a web browser (firefox 15.0.1). (I could check this with telnet webserver 80 and in plain HTML, the answer showed that the output was really not buffered)

I could solve this problem for firefox by also printing the header using the Content-Type meta tag:

 print<<'_EOF_'; <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> _EOF_ 

However, Explorer still seems to be waiting for all the data before displaying the page; I have no other browsers.

+1
source

Compatibility with debian / ubuntu (and Solaris is too explicit) Apache does not define a character set, as on Redhat. The real solution is to simply define it.

on ubuntu, add the following to / etc / apache 2 / httpd.conf

AddDefaultCharset UTF-8

Wihtout, the browser caches the output of the cgi script.

+1
source

For me, this helps disable the deflation module:

 sudo a2dismod deflate 
0
source

Source: https://habr.com/ru/post/1440097/


All Articles