Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

CGI::Simple and mod_perl

by rhumbliner (Sexton)
on Nov 03, 2011 at 00:00 UTC ( #935523=perlquestion: print w/ replies, xml ) Need Help??
rhumbliner has asked for the wisdom of the Perl Monks concerning the following question:

thank you for taking my call ...

i'm using CGI::Simple for a web app running under mod_perl and i've noticed a strange behavior. the following code runs as expected outside of mod_perl:

use CGI::Simple; my $q = new CGI::Simple; my $qh = $q->Vars; ... print $q->header(-charset=>'utf8', -expires=>'+10m'); warn $q->header(-charset=>'utf8', -expires=>'+10m');

where i see the proper header at the client and in apache's error log

but running under mod_perl this code places an empty string in the error log and repeats the expiration date in the header presented to the client! furthermore, if i simply call $q->header() without the print, the header is set properly. i never have to even print the header!

$q->header(-charset=>'utf8', -expires=>'+10m');

i assume this issue has something to do with PerlSendHeader. i've read thru the documentation for porting cgi applications to mod_perl and i'm fairly sure my code is clean. can someone explain to me what's happening here?

Comment on CGI::Simple and mod_perl
Select or Download Code
Re: CGI::Simple and mod_perl
by Anonymous Monk on Nov 03, 2011 at 02:05 UTC

      yup

      "i've read thru the documentation for porting cgi applications to mod_perl..."

      but nothing jumped out at me

Re: CGI::Simple and mod_perl
by Anonymous Monk on Nov 03, 2011 at 03:35 UTC

    i assume this issue has something to do with PerlSendHeader

    Nope.

    sub header { ... if ( $self->{'.mod_perl'} and not $nph ) { my $r = $self->_mod_perl_request(); $r->send_cgi_header( $header ); return ''; } return $header; }

    In short, mod_perl is not CGI

      well i admit that response went right over my head, but i'm reading up on Apache2::Response to see if i can make any sense of it.

        Why? sub CGI::Simple::header doesn't return a header under mod_perl, because mod_perl is not http://tools.ietf.org/html/rfc3875(CGI), so printing the header to STDOUT, is the wrong thing to do

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://935523]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-12-26 02:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (164 votes), past polls