translations and merges

geoff on 2003-08-15T15:52:03

yesterday, I got involved in a conversation on the mod_perl list about using a PerlTransHandler within a <Location> section. of course you can't do this, given the configuration constraints of the directive. however, I had never fully realized the implications <Location> merging until right then.

see, apache actually merges <Location> directives twice - once just prior to the translation phase, then once right after. if you've ever written mod_perl directive handlers then you've probably seen your DIR_MERGE routine called twice per-request, which is the manifestation of this feature (it's also mentioned in a book I've heard about :). anyway, the docs (and code) say that the results of the first merge are thrown away, which they are. however, they are not thrown away until after translation. this means you can peek at what is inside of a <Location> block during translation.

now, of course, the reason you wouldn't want to do that is because some other translation handler can come in and alter the URI and *poof* you're not in the <Location> you thought you were, so it's completely unpredictable. however, it is a pretty cool thing to know, and if you're in complete control of your environment and know what you are doing, then it's a feature that's free to be abused.

cool.