Hello, I am trying to do something like this in PerlAuthenHandler, and it mostly works:
sub auth_handler { my ($r) = @_; ... if ($cond) { $r->set_handlers(PerlResponseHandler => sub { my ($r) = @_; $r->content_type('text/plain'); $r->print("custom handler was here\n"); return Apache2::Const::OK; }); $r->user('dummy-user-for-a-dummy-handler'); return Apache2::Const::OK; } ... } when $cond happens, I get 200 OK with "custom handler was here" instead of whatever is configured as PerlResponseHandler in httpd.conf. So far good. However, when I add mod_rewrite to the mix, it stops working. I want to allow URLs without .pl at the end to be handled by the same .pl script (I only added the Rewrite... directives, the rest was already in httpd.conf): <Directory /somewhere> RewriteCond %{REQUEST_FILENAME} !-d # skip directories RewriteCond %{REQUEST_FILENAME} !-f # skip existing files RewriteCond %{REQUEST_FILENAME}.pl -f # .pl exists, use it instead RewriteRule (.*) $1.pl [L] <Files *.pl> SetHandler perl-script PerlResponseHandler My::Ordinary::Handler </Files> </Directory> Then for requests meeting $cond above I get the following: https://example.com/directory -> 302 to /directory/ (trailing slash, OK) https://example.com/directory/ -> 200 with custom handler as expected https://example.com/directory/index.pl -> 200 with custom handler as expected https://example.com/directory/index -> 200 from My::Ordinary::Handler - FAIL https://example.com/directory/foo.pl -> 200 with custom handler as expected https://example.com/directory/foo -> 200 from My::Ordinary::Handler - FAIL It seems that the auth_handler gets called for all the above requests, but for the failed ones mod_rewrite creates subrequests, which do not inherit the custom PerlResponseHandler set by auth_handler(). How can I replace a PerlResponseHandler even for a subrequest? Or how can I tap to a subrequest creation? Or how can I bypass mod_rewrite from within the PerlAuthenHandler and return my own 200 OK response immediately? Thanks, -Yenya -- | Jan "Yenya" Kasprzak <kas at {fi.muni.cz - work | yenya.net - private}> | | https://www.fi.muni.cz/~kas/ GPG: 4096R/A45477D5 | We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise. --Larry Wall