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

Hi monks,

I am trying to get a page working using Mason and Mod_Perl2. I have lampp set up, and I was following the examples from the Mason book.

I downloaded Mason using CPAN, and I see Mason is installed successfully with lampp's perl by running the following command and receiving the following output: /opt/lampp/bin/perl /opt/lampp/htdocs/mason/handshake.pl Greetings, Martians

This is the content of the script
#start of script #!/usr/bin/perl use strict; use HTML::Mason; my $interp = HTML::Mason::Interp->new( ); my $comp = $interp->make_component(comp_source => <<'END'); Greetings, <% ("Earthlings", "Martians")[rand 2] %> END $interp->exec($comp); #end of script

But when I try to test the second example in the book, which is creating a html file with only one line:

hi Greetings, <% ("Earthlings", "Martians")[rand 2] %>
lampp is complaining that it doesn't return a header, checking the error_log:
[Sun Mar 25 13:28:31 2012] [error] [client 127.0.0.1] malformed header + from script. Bad header=hi Greetings, Earthlings: handshake3.html [Sun Mar 25 13:28:31 2012] [warn] /mason/handshake3.html did not send +an HTTP header

I have in my httpd.conf the following setup:

PerlModule HTML::Mason::ApacheHandler <Location /mason/handshake3.html> SetHandler perl-script PerlHandler HTML::Mason::ApacheHandler </Location>
I tried adding the DefaultType "text/html" line to the Location directive, but it doesn't change anything.

After a day of googling, the answer still shuns me. Would you kind monks please bless your enlightenment upon me.

Replies are listed 'Best First'.
Re: Using Mason with Mod_Perl 2 and getting "did not send an HTTP header" error
by Anonymous Monk on Mar 25, 2012 at 20:05 UTC

    It works for me :/ upgrade?

    $ pmvers HTML::Mason HTML::Mason::ApacheHandler mod_perl2 HTML::Mason: 1.42 HTML::Mason::ApacheHandler: 1.69 mod_perl2: 2.000001

    Maybe use PerlResponseHandler instead of PerlHandler?

    Maybe a bug in DefaultType/AddType ?

      Don't think it's a version issue, I have the following
      HTML::Mason : 1.48 HTML::Mason::ApacheHandler: 1.69 mod_perl2 : 2.000005
      Tried using PerlResponseHandler, but the result is the same.
        Must be a bug in your .conf then
Re: Using Mason with Mod_Perl 2 and getting "did not send an HTTP header" error
by Anonymous Monk on Mar 25, 2012 at 19:29 UTC

    I'm no apache expert, but  <Location /mason/handshake3.html> doesn't appear in the example from masonbook

      I named it handshake3.html, I created many files for this. As long as the directive in httpd.conf matches the name of the file, I don't think it should really matter what the name is.

        I named it handshake3.html, I created many files for this. As long as the directive in httpd.conf matches the name of the file, I don't think it should really matter what the name is.

        And you have a seperate <Location section for each file? Eeeeew :D