mod_perl Tricks

mod_perl Tricks

If you are creating a document from a Registry script and find that
certain browsers are ignoring the Content-Type header and inferring the MIME
type from the script extension in the URI, you can trick the browser into
submission by attaching the "correct" file extension to the end of the
URI in your links.

Unfortunately, you cannot configure authentication in Apache completely
on-the-fly. If you need to enable authentication only under specific
circumstances, the proper approach is somewhat counterintuitive: you need to
enable authentication everywhere, then determine where you don't need it.
In places where you do not need authentication, you can turn it off by setting
the authentication handler stack to OK:

$r->set_handlers(PerlAuthenHandler => [\&OK]);

To toggle Apache's default logging on and off dynamically, use this
configuration combination. First, in your httpd.conf, enable
conditional logging via CustomLog /usr/local/apache/logs/access_log
common env=!SKIP

Then, in your mod_perl handler, turn off logging based on some
condition

$r->subprocess_env->set(SKIP => 1) if $skip_me;

and watch how mod_log_config skips logging the request.

To gather the output from a subrequest, use a combination of the
Apache::URI and LWP classes.