On Fri 29 Feb 2008, J. Peng wrote:
> btw, mapping uri to disk sources in apache2 was done in
> MapToStorageHandler rather than Trans handler, is it?

The Trans handler's task is to decide which file on disk belongs to a certain
URI. So when the Trans handler is done $r->filename must not be empty.

Example: the browser asks for /a/b/c/d/e, DocumentRoot is /var/www. Then after
the core Trans handler $r->filename would be /var/www/a/b/c/d/e.

MapToStorage's task is it then to walk the directory hierarchy, look
for .htaccess files, apply configurations and compute $r->path_info based on
$r->filename. During this process $r->finfo is filled. Hence, you have to
fill it yourself if you change $r->filename after MapToStorage.

Example continued: The entry /var/www/a/b exists on disk either as file or as
directory but /var/www/a/b/c does not. Then after MapToStorage $r->filename
is /var/www/a/b and $r->path_info is /c/d/e.

There is another subtle point, the Trans phase can be skipped entirely. This
happens for file subrequests. In perl they are created by $r->lookup_file
rather than $r->lookup_uri. Such subrequests have an empty $r->uri but a
non-empty $r->filename in the first place. And since there is no URI there is
nothing to translate. They are quite seldom. If asked I'd instantly know of
only one place, mod_negotiation.