On Thu 10 Jan 2008, Vegard Vesterheim wrote:
> The problem I encounter is that the authenticated user is not
> propagated into to the subrequest, so my auth-handler can not do its
> job. The following code is from Apache2::AuthCookie.pm:
>
> =A0 =A0 unless ($r->is_initial_req) {
> =A0 =A0 =A0 =A0 if (defined $r->prev) {
> =A0 =A0 =A0 =A0 =A0 =A0 # we are in a subrequest. =A0Just copy user from =

previous
> request. =A0 =A0 $r->user( $r->prev->user );
>
> I observe that $r->is_initial_req is false (as it should be), but
> $r->prev is undefined, so the authenticated user is not copied into
> the request record. I have verified that the authenticated username
> is available via $r->main->user.
>
> Why does $r->prev return undef in this case?
>
> Would it be ok to copy the autenticated username from $r->main->user
> instead here?


yes.

is_initial_req() is literally the same as (!$r->main and !$r->prev), see=20
server/request.c (httpd-source).

If $r->main is set the current req is a subrequest generated by lookup_uri(=
)=20
or lookup_file(). If $r->prev is set it is an internal redirect generated b=
y=20
internal_redirect() & co.

Torsten