Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the CGI CPAN distribution.

Report information
The Basics
Id: 15482
Status: resolved
Priority: 0/
Queue: CGI

People
Owner: Nobody in particular
Requestors: simon [...] farnz.org.uk
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Running under mod_perl breaks some scripts, by sending headers whenever sub header is called
Perl 5.8.6, CGI.pm 3.10 on Fedora Core 4 (also seen on Fedora Core 1). Mod_perl2 in use on Apache2 --- CGI.pm.orig 2005-11-02 16:25:52.000000000 +0000 +++ CGI.pm 2005-11-02 16:26:05.000000000 +0000 @@ -1451,10 +1451,6 @@ push(@header,map {ucfirst $_} @other); push(@header,"Content-Type: $type") if $type ne ''; my $header = join($CRLF,@header)."${CRLF}${CRLF}"; - if ($MOD_PERL and not $nph) { - $self->r->send_cgi_header($header); - return ''; - } return $header; } END_OF_FUNC fixes it; the script is not an NPH script, but I get headers with $headers = $query->header(-content-type="text/xml"), manipulate them, then try and print them. Those four lines prevent me doing so, and instead leave me with a blank set of headers.
From: pi [...] argilo.net
On Wed Nov 02 11:29:13 2005, guest wrote: Show quoted text
> Perl 5.8.6, CGI.pm 3.10 on Fedora Core 4 (also seen on Fedora Core 1). > Mod_perl2 in use on Apache2 > > --- CGI.pm.orig 2005-11-02 16:25:52.000000000 +0000 > +++ CGI.pm 2005-11-02 16:26:05.000000000 +0000 > @@ -1451,10 +1451,6 @@ > push(@header,map {ucfirst $_} @other); > push(@header,"Content-Type: $type") if $type ne ''; > my $header = join($CRLF,@header)."${CRLF}${CRLF}"; > - if ($MOD_PERL and not $nph) { > - $self->r->send_cgi_header($header); > - return ''; > - } > return $header; > } > END_OF_FUNC > > fixes it; the script is not an NPH script, but I get headers with > $headers = $query->header(-content-type="text/xml"), manipulate > them, then try and print them. Those four lines prevent me doing > so, and instead leave me with a blank set of headers.
I had a similar problem with one of my scripts, which caches pages (together with the corresponding HTTP headers) to a file on the first access so they don't need to be regenerated. Since header() returns an empty string under mod_perl, the headers weren't getting cached and the script failed to run under ModPerl::PerlRun.
On Wed Nov 02 11:29:13 2005, guest wrote: Show quoted text
> Perl 5.8.6, CGI.pm 3.10 on Fedora Core 4 (also seen on Fedora Core 1). > Mod_perl2 in use on Apache2 > > --- CGI.pm.orig 2005-11-02 16:25:52.000000000 +0000 > +++ CGI.pm 2005-11-02 16:26:05.000000000 +0000 > @@ -1451,10 +1451,6 @@ > push(@header,map {ucfirst $_} @other); > push(@header,"Content-Type: $type") if $type ne ''; > my $header = join($CRLF,@header)."${CRLF}${CRLF}"; > - if ($MOD_PERL and not $nph) { > - $self->r->send_cgi_header($header); > - return ''; > - } > return $header; > } > END_OF_FUNC > > fixes it; the script is not an NPH script, but I get headers with > $headers = $query->header(-content-type="text/xml"), manipulate > them, then try and print them. Those four lines prevent me doing > so, and instead leave me with a blank set of headers.
I just posted a ticket about the same problem: https://rt.cpan.org/ Ticket/Display.html?id=25307 I have mod_perl2 too. I fixed the same block in a way that lets it work as it used to for mod_perl 1 because I don't have mod_perl 1 to test it with and I don't want to break anything. I just replaced this line: if ($MOD_PERL and not $nph) { ...with this line: if (($MOD_PERL == 1) and not $nph) { ...to be safe.
P.S. This is the workaround I used in my scripts for the header() and redirect() methods: { local $CGI::MOD_PERL = 0; print $q->header('-status' => '500 Oops','-type' => 'text/ html'); } { local $CGI::MOD_PERL = 0; print $q->redirect('/somewhere/'); }
I'm marking this as 'resolved' because the behavior was previously changed to not always send the headers under modperl > 1: if (($MOD_PERL >= 1) && !$nph) { $self->r->send_cgi_header($header); return ''; } Mark