I am trying to get non-parsed-header scripts to work on an Apache
2.0.49 server with mod_perl installed.
I know that mod_perl is installed properly because the script:
http://www.stupidcensorship.com/cgi-bin/showall.pl
which prints all environment variables, shows:
"MOD_PERL: mod_perl/1.99_12".
(I had thought mod_perl 1.x could not be installed with Apache 2.x,
however it was the default option with my hosting provider, and it
apparently worked -- bonus points if you can explain that one to
me...)
What I did was add these lines to my httpd.conf file:
<Directory /var/www/cgi-bin>
<IfModule mod_perl.c>
<Files ~ (\.pl$)>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
allow from all
PerlSendHeader Off
</Files>
</IfModule>
<IfModule sapi_apache2.c>
AddType text/plain .php .php4 .php3 .phtml
php_admin_flag engine off
</IfModule>
Options -Includes -ExecCGI
</Directory>
The problem is that non-parsed-header scripts are not working. In
theory, if a non-parsed-header script prints "HTTP/1.1 200 OK\n" and
"Content-type: text/html\n\n" as its first lines, the server should
send that to the browser as the HTTP headers. However, when I access
a script like:
http://www.stupidcensorship.com/cgi-bin/nph-send-200-ok-and-content-type-text-html-and-hello-world.pl
which sends those lines as output, what happens is that the Web server
apparently inserts a "text/plain" header, and then the browser just
displays the lines that I tried to print:
>>>
HTTP/1.1 200 OK
Content-type: text/html
hello world
>>>
(You'll want to view the URL above in Firefox; IE gets confused and
tries to save the file.)
How do I make the Web server actually take the lines that I'm
printing, and use them for the actual HTTP headers the way it's
supposed to?
Incidentally, I get the same result if I remove the "nph-" prefix from
the filename:
http://www.stupidcensorship.com/cgi-bin/send-200-ok-and-content-type-text-html-and-hello-world.pl
Is the probelm that the Web server is ignoring the nph- prefix and not
paying attention to the "non-parsed-header-ness" of the file?
I have read on a million different Web sites, "for nph scripts, set
PerlSendHeader to 'Off'", but as you can see in the excerpt from my
.conf file above, I've done that already and it didn't fix it.
p.s. added at the last minute: I also read that you have to add
"local($|)= 1 ;" to an nph script to make it work under mod_perl; I
tried that but still got the same results as above. |