Sarq has asked for the wisdom of the Perl Monks concerning the following question:

Hello, For some reason, my Mod Perl is automatically printing the content header as Content-type: text/html and I would like to have it not print out any content headers at all w/o my physical execution of such print commands. Any help would be GREATLY appreciated. Ben

Replies are listed 'Best First'.
Re: Mod Perl Content Header Output
by Hrunting (Pilgrim) on Dec 21, 2000 at 02:49 UTC
    There's a server configuration variable 'PerlSendHeader'. Set it to 'off' to send your own headers (I believe, it's actually different on my server conf, but this is what the man page says).

    This exact question and many exactly like it are answer in the mod_perl Guide (which appears to be down as I write this). This is one of the most frequently asked questions by people starting.

    Also, 'man cgi_to_mod_perl'.

      I set the PerlSendHeader to 'off' in my httpd.conf configuration but i am still getting a content-type header printed out by apache. Under mod_perl this test script outputs to my browser the following:
      Content-type:image/gif
      Here's my test.cgi script which is inside my mod_perl directory (/home/httpd/perl/).
      #!/usr/bin/perl -w use strict; if ($ENV{'MOD_PERL'}){ print "Content-type:image/gif\n\n"; #my image output will go here }else{ print "Content-type:text/html\n\n"; print "MOD_PERL is off"; } exit;
      And here's my httpd.conf settings.
      <IfModule mod_perl.c> Alias /perl/ /home/httpd/perl/ <Location /perl> SetHandler perl-script PerlHandler Apache::Registry Options +ExecCGI PerlSendHeader off </Location> </IfModule>
      I restarted apache and did a killall -HUP apache. As you can see by the output of the script, mod_perl is working. I'm running mod_perl/1.23. Anybody have any ideas on how i can fix this? I'd like to be able to output more than just text/html files with mod_perl.

      thanks monks,
      james

      p.s. i tried "PerlSendHeader off" and "PerlSendHeader Off"

        It's the other way around. PerlSendHeader should be *ON*. From the ModPerl documentation:

        The PerlSendHeader On directive tells mod_perl to intercept anything that looks like a header line (such as Content-Type: text/plain) and automatically turn it into a correctly formatted HTTP/1.0 header, the same way it happens with CGI scripts running under mod_cgi. This allows you to keep your CGI scripts unmodified.
        oh crap, you are absolutely right. lol. May my stupidity be a shining beacon for those who follow in my footsteps.
        thanks very much.
        jtrue
Re: Mod Perl Content Header Output
by merlyn (Sage) on Dec 21, 2000 at 02:19 UTC
    • Why is this under "CGI Programming"? mod_perl is not mod_cgi. Different technologies.
    • What is your current configuration? Are you talking about Apache::Registry or some other pre-rolled handler or a handler of your own?