mod_perl2 / apache2 status codes
mod_perl2 / apache2 status codes
am 04.03.2008 03:59:04 von yoder
--Apple-Mail-2-806561879
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit
Hi,
I can't seem to find a resource that helps me with this problem.
Dropping in mod_perl2 seems to change the status code of a simple CGI
script:
use CGI;
use CGI::Carp qw(fatalsToBrowser); # show fatal error messages
in browser
my $query = new CGI;
my $status = "400 Bad Request";
print $query->header( -type => 'text/plain', -status => $status );
print "TESTING 400 BAD REQUEST";
exit;
Under plain CGI, this returns a response:
TESTING 400 BAD REQUEST
and a check of the response gives back 400.
However, under mod_perl2, I get back this
TESTING 400 BAD REQUEST
200 OK
OK
Your browser sent a request that this server could not
understand.
Apache/2.2.8 (Unix) DAV/2 mod_perl/2.0.3 Perl/v5.8.8 Server
at localhost Port 8080
The html message is from a 400 document, but the title (and response
status) are 200 OK (not to mention their shouldn't be a html message
for plain text). No amount of fiddling with options or googling has
had any yield.
Any help would be appreciated.
Michael Yoder
yoder@mystrands.com
Additional Info:
This is a fresh install of darwinports, and via darwinports
perl,apache2,mod_perl2 on a OSX 10.5 Leopard macbook pro.
Server configuration:
NameVirtualHost *
ServerAdmin mod_perl@localhost
ServerSignature On
DocumentRoot /opt/local/apache2/cgi-bin
LogLevel warn
ErrorLog /opt/local/apache2/logs/error_log
CustomLog /opt/local/apache2/logs/access_log combined
PerlOptions +ParseHeaders
PerlTaintCheck On
PerlWarn On
PerlConfigRequire /opt/local/apache2/cgi-bin/rec/
mod_perl_startup.pl
# ModPerl::Registry mode (just change URL to run in different mode)
Alias /perl-bin/ /opt/local/apache2/cgi-bin/
# ModPerl::PerlRun mode (just change URL to run in different mode)
Alias /perlrun-bin/ /opt/local/apache2/cgi-bin/
# perl stays in memory, scripts loaded at startup as well
Options +ExecCGI
PerlOptions +ParseHeaders
SetHandler perl-script
PerlHandler ModPerl::Registry
Order allow,deny
Allow from all
# perl stays in memory, scripts loaded each time
Options +ExecCGI
PerlOptions +ParseHeaders
SetHandler perl-script
PerlHandler ModPerl::PerlRun
Order allow,deny
Allow from all
Startup Script:
use lib "/opt/local/apache2/cgi-bin/rec";
use Log::Log4perl ();
use ModPerl::Registry ();
1;
--Apple-Mail-2-806561879
Content-Type: text/html;
charset=US-ASCII
Content-Transfer-Encoding: quoted-printable
-webkit-line-break: after-white-space; ">Hi,
class=3D"webkit-block-placeholder">
I can't seem to find a =
resource that helps me with this problem. Dropping in mod_perl2 seems to =
change the status code of a simple CGI script:
class=3D"webkit-block-placeholder">
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
normal normal 11px/normal Monaco; color: rgb(160, 32, 240); =
"> use CGI
style=3D"color: #b22200">;
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
normal normal 11px/normal Monaco; color: rgb(178, 0, 34); ">
style=3D"color: #a020f0"> use
style=3D"color: #000000">CGI::Carp
#a020f0">qw(fatalsToBrowser); =
# show fatal error messages in browser
margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: =
rgb(178, 34, 0); "> my =
$
#a000f0">query =3D
style=3D"color: #a020f0">new
#000000">CGI;
0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
11px/normal Monaco; color: rgb(0, 0, 255); ">
#b22200"> my =
$
#a000f0">status
style=3D"color: #b22200">=3D "400 Bad Request"
#b22200">;
0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
11px/normal Monaco; color: rgb(178, 0, 34); ">
class=3D"Apple-style-span" style=3D"color: rgb(0, 0, 0); "> =
print $
#a000f0">query
#b22200">->header( -type =
=3D>
#0000ff">'text/plain', =
-status =3D> $
style=3D"color: #a000f0">status
#b22200">);
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
normal normal 11px/normal Monaco; color: rgb(0, 0, 255); ">
style=3D"color: #b22200">
#a000f0">print "TESTING 400 BAD REQUEST"
#b22200">;
margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
11px/normal Monaco; color: rgb(178, 34, 0); ">
style=3D"color: #a020f0">exit;
Under plain CGI, this returns a =
response:
class=3D"webkit-block-placeholder">
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;">
class=3D"Apple-style-span" color=3D"#030303"> =
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;">
color=3D"#030303">TESTING 400 BAD =
REQUEST
and a check of the =
response gives back 400.
class=3D"webkit-block-placeholder">
However, under =
mod_perl2, I get back this
class=3D"webkit-block-placeholder">
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;">TESTING 400 BAD =
REQUEST<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML =
2.0//EN">
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
normal normal 12px/normal Helvetica; ">
face=3D"'Courier New'"><html><head>
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; font: normal normal normal 12px/normal Helvetica; =
">
New'"><title>200 OK</title>
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; font: normal normal normal 12px/normal Helvetica; =
">
New'"></head><body>
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 12px/normal Helvetica; ">
class=3D"Apple-style-span" face=3D"'Courier =
New'"><h1>OK</h1>
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
normal normal 12px/normal Helvetica; ">
face=3D"'Courier New'"><p>Your browser sent a request that this =
server could not understand.<br />
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; font: normal normal normal 12px/normal Helvetica; =
">
New'"></p>
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
normal normal 12px/normal Helvetica; ">
face=3D"'Courier New'"><hr>
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 12px/normal Helvetica; ">
class=3D"Apple-style-span" face=3D"'Courier =
New'"><address>Apache/2.2.8 (Unix) DAV/2 mod_perl/2.0.3 =
Perl/v5.8.8 Server at localhost Port =
8080</address>
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
normal normal 12px/normal Helvetica; ">
face=3D"'Courier New'"></body></html>
The html message is from a 400 =
document, but the title (and response status) are 200 OK (not to mention =
their shouldn't be a html message for plain text). No amount of fiddling =
with options or googling has had any yield.
class=3D"webkit-block-placeholder">
Any help would be =
appreciated.
class=3D"webkit-block-placeholder">
Michael Yoder
href=3D"mailto:yoder@mystrands.com">yoder@mystrands.com
class=3D"webkit-block-placeholder">
Additional =
Info:
This is a fresh install of darwinports, and via =
darwinports perl,apache2,mod_perl2 on a OSX 10.5 Leopard macbook =
pro.
Server configuration:
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;">NameVirtualHost =
*
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"><VirtualHost =
*>
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> ServerAdmin =
mod_perl@localhost
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;"> =
ServerSignature On
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;"> =
DocumentRoot =
/opt/local/apache2/cgi-bin
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;"> =
LogLevel warn
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;"> =
ErrorLog =
/opt/local/apache2/logs/error_log
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;"> =
CustomLog /opt/local/apache2/logs/access_log =
combined
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;">
class=3D"webkit-block-placeholder">
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;"> =
PerlOptions +ParseHeaders
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;"> =
PerlTaintCheck On
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;"> =
PerlWarn On
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> PerlConfigRequire =
/opt/local/apache2/cgi-bin/rec/mod_perl_startup.pl
>
class=3D"Apple-style-span" style=3D"font-size: 12px;">
class=3D"webkit-block-placeholder">
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;"> =
# ModPerl::Registry mode (just change URL to run in different =
mode)
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> Alias /perl-bin/ =
/opt/local/apache2/cgi-bin/
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;"> =
# ModPerl::PerlRun mode (just change URL to run in different =
mode)
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> Alias /perlrun-bin/ =
/opt/local/apache2/cgi-bin/
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;">
class=3D"webkit-block-placeholder">
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;"> =
# perl stays in memory, scripts loaded at startup as =
well
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> <Location =
/perl-bin/>
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> Options =
+ExecCGI
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> PerlOptions =
+ParseHeaders
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> SetHandler =
perl-script
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> PerlHandler =
ModPerl::Registry
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> Order =
allow,deny
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> Allow from =
all
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> =
</Location>
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;">
class=3D"webkit-block-placeholder">
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;"> =
# perl stays in memory, scripts loaded each =
time
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> <Location =
/perlrun-bin/>
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> Options =
+ExecCGI
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> PerlOptions =
+ParseHeaders
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> SetHandler =
perl-script
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> PerlHandler =
ModPerl::PerlRun
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> Order =
allow,deny
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> Allow from =
all
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;"> =
</Location>
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: =
12px;"></VirtualHost>
class=3D"webkit-block-placeholder">
Startup =
Script:
New'" size=3D"3">
12px;">use lib =
"/opt/local/apache2/cgi-bin/rec";
class=3D"Apple-style-span" face=3D"'Courier New'" size=3D"3">
class=3D"Apple-style-span" style=3D"font-size: 12px;">use Log::Log4perl =
();
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: 12px;">use ModPerl::Registry =
();
face=3D"'Courier New'" size=3D"3">
style=3D"font-size: =
12px;">1;
class=3D"webkit-block-placeholder">
class=3D"webkit-block-placeholder">
class=3D"webkit-block-placeholder">
class=3D"webkit-block-placeholder">
=
--Apple-Mail-2-806561879--