"be consistent" | |
PerlMonks |
mod_perl and CGI::headerby saberworks (Curate) |
on Sep 29, 2005 at 23:22 UTC ( [id://496282]=perlquestion: print w/replies, xml ) | Need Help?? |
saberworks has asked for the wisdom of the Perl Monks concerning the following question:
I ran into a frustrating issue today at work. Frustrating because it took me a while to figure out what was going on. We have an application which runs on mod_perl under a handler called PerlDo. I recently started here so I'm not sure whether PerlDo is a custom handler or released by someone. Anyway, I was trying to print some arbitrary HTTP headers to communicate with a client application which is not a regular web browser. These headers were something like: "X-error-code" So inside my "cgi" script (which runs under PerlDo, which in turn runs under mod_perl, so PerlDo seems similar to Apache::Registry), I did this: According to the CGI.pm docs, the CGI::header method is supposed to discard the leading dash, turn underscores into dashes, format the header, and return it. So you have to print it. However, my headers were never sent. In fact, $cgi->header() didn't even return them. I tested a small test script on advice in the chatterbox and it works fine: So I dug around in CGI.pm and in the header method I found this code: I'm assuming this means CGI.pm wants to think it is smart enough to dispatch the headers instead of just returning them IF it is running under mod_perl. To me, this seems like an extremely silly assumption (pretend I'm using the formatted headers for something else, not just printing them). Furthermore, even if it did want to do that, apparently passing them to the r->send_cgi_header method isn't working regardless. And it won't return the actual header. Will someone please explain this behavior? Thanks in advance.
Back to
Seekers of Perl Wisdom
|
|