Hello all,

I have the following question on which I would appreciate any insight.

I have written a failry simple multiplexing PerlTransHandler. Its task 
is to check the uri and if it matches a certain string then push an 
associated PerlHandler onto the stack. An example can make it clearer:

Let's say I make the following request:

GET /action1/arg1

The PerlTransHandler has a hash, mapping actions to modules like that:

%h = (
        '/action1' => My::Module1,
        '/action2' => My::Module2,
);

so by checking all the keys of the hash against the uri with a regex it 
will eventually match the '/action1' and do the following:

$r->push_handlers(PerlHandler => $h{action1});

More importantly it will also set the path_info to the rest of the uri, 
ie /arg1, so that it can later be read by the PerlHandler that was 
pushed onto the stack:

$r->path_info('/arg1');

and finally:

return OK;

so that no other PerlTransHandler is invoked.

Up to here everything works fine and eventually the PerlHander 
My::Module1 is invoked and the path_info is read correctly.

My problem arose when I added some debugging info to the 
PerlTransHandler and I realized that it was actually invoked twice for 
each request!

I realized this by tracing the current_callback, URI and path_info in my 
error logs. When I did that I got two consecutive entries from the 
translation handler:

PerlTransHandler URI=/action1/arg1 path_info=
PerlTransHandler URI=/arg1 path_info=
PerlHandler URI=/action1/arg1 path_info=/arg1

My question is why does the second line appear? I never made an explicit 
request for this URI (/arg1).

By doing some extra testing I realized that if I don't set the path_info 
in my PerlTransHandler then I avoid the duplication. But I still do not 
understand why if I set the path_info so that my PerlHandler can read 
its arguments from there I get the duplication effect. My scripts work 
perfectly well so this is more of an academic issue but still any help 
would be greatly appreciated.

Many thanks,
Giorgos

Reply via email to