You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Carl Brewer <ca...@vivitec.com.au> on 2003/11/12 02:40:34 UTC

[users@httpd] apache 2.0.48 unbuffered output from perl script (CGI)

Hello,

I'm trying to unbuffer output from some long running
perl scripts that run through CGI (not mod_perl).

A script example is :

#!/usr/bin/perl

print "Content-type: text/html\n\n";

my $i = 0;
$| = 0;

while ($i < 10) {
     print "$i<BR>\n";
     sleep 2;
     $i++;
}


I'm running this on Redhat 7.3 under apache 2.0.48
We could get this to work fine with 1.3.x, as we
were using mod_gzip we'd set the following :

<Files foo.pl>
     mod_gzip_on No
</Files>

And the output would be suitably unbuffered. But, with 2.0 I'm
unable to get the same response (same browser, Mozilla 1.5)

My mod_deflate settings for the virthost I'm testing on are :


     <Location />
         SetOutputFilter DEFLATE
         # Netscape 4.x has some problems...
         BrowserMatch ^Mozilla/4 gzip-only-text/html
         # Netscape 4.06-4.08 have some more problems
         BrowserMatch ^Mozilla/4\.0[678] no-gzip
         # MSIE masquerades as Netscape, but it is fine
         BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
         # Don't compress images
         SetEnvIfNoCase Request_URI \
         \.(?:gif|jpe?g|png)$ no-gzip dont-vary
     </Location>


We're running reverse proxies, but not for this particular
directory.

When I turned off mod_deflate I still saw the same (buffered!)
behaviour.  Can anyone make any suggestions re what I've done wrong?
I've searched through the archives and FAQ etc but not found
anything that seemed useful, but I may have missed something
obvious!

thanks
Carl




-- 
=======================
Vivitec Pty. Ltd.
Suite 6, 51-55 City Rd.
Southbank, 3006.
Ph. +61 3 8626 5626
Fax +61 3 9682 1000
=======================


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] apache 2.0.48 unbuffered output from perl script (CGI)

Posted by Carl Brewer <ca...@vivitec.com.au>.
Carl Brewer wrote:


> When I turned off mod_deflate I still saw the same (buffered!)
> behaviour.  Can anyone make any suggestions re what I've done wrong?
> I've searched through the archives and FAQ etc but not found
> anything that seemed useful, but I may have missed something
> obvious!

When I turned compression off properly (!) I got unbuffered output.

For the archives :

Here's how I tested it.

lynx --source --mime_header http://url | less
so I can see if it's compressed or not.

Here's how I selectively turned off compression for
various scripts (I did this in .htaccess, but it works
just as well in httpd.conf)


# config to turn off deflate for apache2 for various scripts that run
# unbuffered output
SetEnvIfNoCase Request_URI emailmanage.pl no-gzip dont-vary
SetEnvIfNoCase Request_URI makekeywords.pl no-gzip dont-vary
SetEnvIfNoCase Request_URI cleanup.pl no-gzip dont-vary

Maybe there's a neater way to do this, but this works.

Carl


-- 
=======================
Vivitec Pty. Ltd.
Suite 6, 51-55 City Rd.
Southbank, 3006.
Ph. +61 3 8626 5626
Fax +61 3 9682 1000
=======================


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] apache 2.0.48 unbuffered output from perl script (CGI)

Posted by Robert Andersson <ro...@profundis.nu>.
Carl Brewer wrote:
> Ahha, yes. You're quite right - slip of the fingers in cutting &
> pasting.  $| = 1 makes no difference, as that's what's in the
> actual script.

I remember that is some issue (yet unresolved, I think) with CGI and
buffering in Apache 2.0. I cannot give any details, but try search the bug
database and I think you will find plenty of discussion. Perhaps also this
list's archive as well as the developer list.

Regards,
Robert Andersson


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] apache 2.0.48 unbuffered output from perl script (CGI)

Posted by Carl Brewer <ca...@vivitec.com.au>.
Aaron Morris wrote:


> Well, I can tell you one problem.  You have explicitly enabled buffered 
> output in perl.  $| should be set to any non-zero value to disable 
> buffered output.

Ahha, yes. You're quite right - slip of the fingers in cutting &
pasting.  $| = 1 makes no difference, as that's what's in the
actual script.

Carl


-- 
=======================
Vivitec Pty. Ltd.
Suite 6, 51-55 City Rd.
Southbank, 3006.
Ph. +61 3 8626 5626
Fax +61 3 9682 1000
=======================


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] apache 2.0.48 unbuffered output from perl script (CGI)

Posted by Aaron Morris <aa...@mindspring.com>.

Carl Brewer wrote:
> 
> Hello,
> 
> I'm trying to unbuffer output from some long running
> perl scripts that run through CGI (not mod_perl).
> 
> A script example is :
> 
> #!/usr/bin/perl
> 
> print "Content-type: text/html\n\n";
> 
> my $i = 0;
> $| = 0;
> 
> while ($i < 10) {
>     print "$i<BR>\n";
>     sleep 2;
>     $i++;
> }
> 
> thanks
> Carl

Well, I can tell you one problem.  You have explicitly enabled buffered 
output in perl.  $| should be set to any non-zero value to disable 
buffered output.

-- 
Aaron W Morris <aa...@mindspring.com> (decep)




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org