mr.nick has asked for the wisdom of the Perl Monks concerning the following question:

This borders on being more a question about Apache 2.0 than it does Perl, I'm just hoping that there is a Perl solution to my problem.

I have a CGI script that bounces back a binary file that is many megabytes in size. The script outputs the HTTP headers (complete with mimetype and Content-Disposition: filename=) and then sends the data.

Under Apache 1.3.x, I could put a simple $|=1 at the top of my code and all would work as expected. Under Apache 2.0x, this doesn't work. The entire file must come down the pipe first before you get prompted as to how to handle the it.

Apache 2.0 is buffering my output somehow (or forcing my Perl script back to $|=0).

Is anyone aware of an Apache::* module (or other) that I could potentionally use to bypass this? I presume that the CGI handler for Apache 2.0 is automatically buffering the results, regardless of what the actual script itself is doing. I'm hoping there exists something that bypasses the CGI handler is some way.

Hm. mod_perl perhaps. Except I didn't have luck getting it to work with Apache 2.0 (which, ugh, I must use) last time I tried.

Suggestions? Comments? Thanks!

Replies are listed 'Best First'.
Re: Output buffering under Apache
by bastard (Hermit) on Mar 01, 2001 at 20:30 UTC
    I'm not sure of any modules, but this thread covers about the same topic, and it's only a few days old.
    It should cover what you are looking for.

    Hope it helps.

      That thread doesn't really cover the same topic; close but not really. I'm looking to unbuffer output by avoiding Apache's CGI handler, that was more about preventing the user/browser from timing out when waiting on ANY data to appear.
        As was said in the other thread by Merlyn:
        This works under modern Apache, but under older Apache versions, the script
        also had to be named nph-something to turn off the buffering. Consider the name
        as a signal that Apache should do its own $| = 1 equivalent.

        I don't know why it doesnt work under 2.0 apache, but try renaming the script "nph-..." and looking into the docs on CGI.pm. That is how you get around apache's buffering.