Mailing List Archive

Problems with DocumentRoot behaviour...
I'm writing an Access Module (PerlAccessHandler), and within the Access Handler
I'm trying to do similar to an Internal Redirect, using Custom Response. ie;
$r->custom_response(FORBIDDEN,"/the/other/URI");
return FORBIDDEN;

The effect I'm after is, depending on certain conditions, a different page will
be shown (without a change in the URL). Part of the problem is this happens
during the Access phase, and I cannot override the normal Handler phase (due to
this being used with CGI's, etc...).

Things all work as they should, except where the URI is for a directory, and
thus using DocumentRoot to derive the filename. It DOES derive the correct
filename, but redirecting using custom_response does NOT seem to work at all
when accessing a URI directory. Instead of the target URI being shown, you get
the standard FORBIDDEN handler. ie; It's ignoring the custom_response
handler...

What's going on here, and how can I fix it? ^_^
Are there any alternative ways to redirect internally at the Access phase?

Thanks in advance...

--
. Trevor Phillips - http://jurai.murdoch.edu.au/ .
: Web Systems Administrator - T.Phillips@murdoch.edu.au :
| IT Services - Murdoch University |
>------------------- Member of the #SAS# & #CFC# --------------------<
| On nights such as this, evil deeds are done. And good deeds, of /
| course. But mostly evil, on the whole. /
\ -- (Terry Pratchett, Wyrd Sisters) /
Re: Problems with DocumentRoot behaviour... [ In reply to ]
Hi there,

On Mon, 21 Feb 2000, Trevor Phillips wrote:

> The effect I'm after is, depending on certain conditions, a
> different page will be shown (without a change in the URL). Part of
> the problem is this happens during the Access phase, and I cannot
> override the normal Handler phase (due to this being used with
> CGI's, etc...).

The Eagle Book, page 466, says of $r->set_handlers():

"If you would like to change the list of Perl handlers configured for
the current request, you can change it with set_handlers()."

> Things all work as they should, except where the URI is for a
> directory, and thus using DocumentRoot to derive the filename. It
> DOES derive the correct filename, but redirecting using
> custom_response does NOT seem to work at all when accessing a URI
> directory. Instead of the target URI being shown, you get the
> standard FORBIDDEN handler. ie; It's ignoring the custom_response
> handler...

The Eagle Book, page 169, says of the $r->custom_response() method:

"This method takes two arguments: the status code of the response you
want to handle and the URI of the document or module that you want to
pass control to."

I'm not a bit surprised that if you don't pass what's expected you
don't get what's expected. Could you try passing a module name and
do some processing in there to achieve the desired effect?

Hope this helps,

73,
Ged.
Re: Problems with DocumentRoot behaviour... [ In reply to ]
"G.W. Haywood" wrote:
>
> On Mon, 21 Feb 2000, Trevor Phillips wrote:
>
> > The effect I'm after is, depending on certain conditions, a
> > different page will be shown (without a change in the URL). Part of
> > the problem is this happens during the Access phase, and I cannot
> > override the normal Handler phase (due to this being used with
> > CGI's, etc...).
>
> The Eagle Book, page 466, says of $r->set_handlers():
>
> "If you would like to change the list of Perl handlers configured for
> the current request, you can change it with set_handlers()."

I have tried this, and it does not work. This is how I was initially doing it:

$r->handler("perl-script");
$r->set_handlers(PerlHandler=>[\&MyHandler]);

However, this doesn't seem to work unless the Handler is already set to
perl-script. I couldn't get it working on plain HTML files, or CGI's...
(Otherwise I definitely would use this as it is the neater solution).

> > Things all work as they should, except where the URI is for a
> > directory, and thus using DocumentRoot to derive the filename. It
> > DOES derive the correct filename, but redirecting using
> > custom_response does NOT seem to work at all when accessing a URI
> > directory. Instead of the target URI being shown, you get the
> > standard FORBIDDEN handler. ie; It's ignoring the custom_response
> > handler...
>
> The Eagle Book, page 169, says of the $r->custom_response() method:
>
> "This method takes two arguments: the status code of the response you
> want to handle and the URI of the document or module that you want to
> pass control to."
>
> I'm not a bit surprised that if you don't pass what's expected you
> don't get what's expected. Could you try passing a module name and
> do some processing in there to achieve the desired effect?

Eh? I am passing what's expected! I have said Eagle Book sitting next to me,
and have tried the techniques listed, and it still has problems! As I said,
custom_response works FINE where the initial URI is a file within a folder
(/something/afile.html), but does not when it points to a directory, kicking in
with the DocumentRoot path evaluation (/something/ => /something/index.html).

I'm not talking about the URI redirected to by custom_response - that is
Static.

> Hope this helps,

No, not really. I've tried the first technique, and it didn't work. The second
technique I am doing as documented in the Eagle Book, and it doesn't work
either (when the initial URL is a Directory URI).

Any other ideas?

--
. Trevor Phillips - http://jurai.murdoch.edu.au/ .
: Web Systems Administrator - T.Phillips@murdoch.edu.au :
| IT Services - Murdoch University |
>------------------- Member of the #SAS# & #CFC# --------------------<
| On nights such as this, evil deeds are done. And good deeds, of /
| course. But mostly evil, on the whole. /
\ -- (Terry Pratchett, Wyrd Sisters) /
Re: Problems with DocumentRoot behaviour... [ In reply to ]
Hi again,

On Wed, 23 Feb 2000, Trevor Phillips wrote:

> "G.W. Haywood" wrote:
> >
> > On Mon, 21 Feb 2000, Trevor Phillips wrote:
> >
> > > The effect I'm after is, depending on certain conditions, a
> > > different page will be shown (without a change in the URL). Part of
> > > the problem is this happens during the Access phase, and I cannot
> > > override the normal Handler phase (due to this being used with
> > > CGI's, etc...).
> >
> > The Eagle Book, page 466, says of $r->set_handlers():
> >
> > "If you would like to change the list of Perl handlers configured for
> > the current request, you can change it with set_handlers()."
>
> I have tried this, and it does not work. This is how I was initially doing it:
>
> $r->handler("perl-script");
> $r->set_handlers(PerlHandler=>[\&MyHandler]);

Of handler(), the Eagle Book p.444 says: "handler() cannot be used to
set handlers for anything but the response phase", you said
> > > the problem is this happens during the Access phase

What are the conditions when you want to invoke your handler?
Can I have a look at it?

Can you see a way to use a handler which handles everything, but which
returns DECLINED for cases where you *don't* want your special page?
There are examples of that kind in the book.

> Eh? I am passing what's expected!

Don't be upset - but I really don't think so. The book definitely
says "the URI of the document or module". A directory is neither.

> Any other ideas?

Ooooh, lots. If you like we can do something using the C API, then we
could get *really* unruly:)

73,
Ged.