in reply to Need help with CGI script that won't complete running

I've come up with a solution that solved my problem. I made a filter that unsets the content length. I don't have Apache 2 installed here, I wrote this blind, walked the client through installing and configuring it and SWOOSH, fixed the problem on the first try. (Love that feeling.. so very rare.)

It's got a little bit of kruft (see $context) because I based it on a module featured on perl.com about Apache2 Filters. It will probably work if you remove the $context code but I'm not sure and don't have apache 2 to test.. (Can we get at the filters from mod_cgi in 2.x?, do we have to do NPH? It would be nice if we could just fix this in CGI with a use statement instead of screwing with Apache's config...)

I'm going to try and get 2.* running on a box here so I can remove the kruft.

Update
Removed kruft and tested.
package Apache2Kludge; use 5.006; use strict; use warnings; use Apache::Filter (); # $f use Apache::RequestRec (); # $r use Apache::RequestUtil (); # $r->dir_config() use APR::Table (); # dir_config->get() and headers_out->get() use Apache::Const -compile => qw(OK DECLINED); our $VERSION = '0.03'; sub handler { my $f = shift; my $r = $f->r; unless ($f->ctx) { # Only does this when the filter is first called. $r->headers_out->unset('Content-Length'); } # retrieve the filter context, which was set up on the first invocat +ion my $context = $f->ctx; while ($f->read(my $buffer, 1024)) { $f->print($buffer); } $f->ctx($context); return Apache::OK; } 1; __END__ =head1 NAME Apache2Kludge - mod_perl OutputFilterHandler for removing the Content- +Length for CGI scripts =head1 SYNOPSIS #In Apache 2.0 config PerlModule Apache2Kludge <Location /cgi-bin/SCRIPTNAME.pl> SetHandler perl-script PerlResponseHandler ModPerl::PerlRun PerlOutputFilterHandler Apache2Kludge PerlOptions +ParseHeaders Options +ExecCGI </Location> This module implements an Apache 2.0 output filter that removes the Co +ntent-Length for scripts that worked under Apache 1.3 mod_cgi, but won't run under Apache 2.0 =head1 DESCRIPTION This module implements an Apache 2.0 output filter that removes the Co +ntent-Length for scripts that worked under Apache 1.3 mod_cgi, but won't run under Apache 2.0 When I encountered this problem, no one had a fix, and looking around +I found many other people having this same problem. The problem seems to come from Apache sending the Content-Length prema +turely. The error generated in the logs when the script fails is (70007)The timeout specified has expired: ap_content_length_filter: ap +r_bucket_read() failed This can also be indicitive of other problems. The Apache side of the configuration happens like so #In Apache 2.0 config PerlModule Apache2Kludge <Location /cgi-bin/SCRIPTNAME.pl> SetHandler perl-script PerlResponseHandler ModPerl::PerlRun PerlOutputFilterHandler Apache2Kludge PerlOptions +ParseHeaders Options +ExecCGI </Location> =head2 EXPORT None by default. =head1 AUTHOR Lee Pumphret, E<lt>perl+REMOVETHIS+@+ANDTHAT+leeland.netE<gt> =head1 COPYRIGHT This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. =head1 L<perl>. =cut


-Lee

"To be civilized is to deny one's nature."