Subject: | Fatal exception thrown under Mod_perl2 if a "bad request" issued |
When using CAP::Dispatch in combination with Mod_perl2, if you issue
a "bad request" (e.g. by sending invalid characters in a module name),
CAP::Dispatch throws a "500 - Internal Server Error".
This gets logged in the Apache error log to the effect of:
Undefined subroutine &CGI::Application::Dispatch::BAD_REQUEST called
at ...
Did a bit of poking through 2.10, and see that this is due to the way
that Mod_perl2 names the "bad request" constant; previous versions
named it "BAD_REQUEST", while under Mod_perl2 its
named "HTTP_BAD_REQUEST".
The attached patch addresses this by fixing up the return code when we
want to return "the http bad request response"; under Mod_perl2 it now
returns "HTTP_BAD_REQUEST" while for everything else it continues to
return "BAD_REQUEST".
Subject: | cap-dispatch-bad-request-modperl2.patch |
diff -rc CGI-Application-Dispatch-2.10.orig/lib/CGI/Application/Dispatch.pm CGI-Application-Dispatch-2.10/lib/CGI/Application/Dispatch.pm
*** CGI-Application-Dispatch-2.10.orig/lib/CGI/Application/Dispatch.pm 2007-01-15 06:03:05.000000000 -0800
--- CGI-Application-Dispatch-2.10/lib/CGI/Application/Dispatch.pm 2007-08-24 09:42:27.549666502 -0700
***************
*** 671,677 ****
} elsif( $r->status == 500 ) {
return SERVER_ERROR();
} elsif( $r->status == 400 ) {
! return BAD_REQUEST();
} else {
return OK();
}
--- 671,677 ----
} elsif( $r->status == 500 ) {
return SERVER_ERROR();
} elsif( $r->status == 400 ) {
! return IS_MODPERL_2 ? HTTP_BAD_REQUEST() : BAD_REQUEST();
} else {
return OK();
}