On Thu, Jan 20, 2005 at 02:32:59PM -0800, Philippe M. Chiasson wrote:
> Dorian Taylor wrote:
> >suppose i wanted the same logic as:
> >
> >    return Apache::DECLINED unless $r->is_initial_req;
> >
> >except that sometimes it may be necessary to serve for a subrequest,
> >just not more than once. the construct i tried is:
> >
> >    for (my $pr = $r; $pr; $pr = $pr->prev) {
> >        if ($pr->notes->get(__PACKAGE__ . '::SEEN')) {
> >            $r->log->debug("We've been seen already.");
> >            return Apache::DECLINED;
> >        }       
> >    }
> >    $r->notes->set(__PACKAGE__ . '::SEEN', 1);
> 
> That's because you are setting that SEEN flag in the subrequest itself,
> and that subrequest will most likely be short lived. Nobody will see that
> flag, unless that subrequest fires off another subrequest of it's own.

that's exactly it. the subrequest does in fact launch subrequests
of its own. it's possible that hits to the uri handled by this
handler may come by way of a lookup_uri from another handler, so a
test to is_initial_req or is_main won't suffice. the desired effect
is this:

GET /foo [handled by mod_foo]
  `-> lookup_uri /somewhere/else [handled by this module]
      `-> lookup_uri /somewhere/else/again [same, but return declined]

exactly as if the first request to /somewhere/else was the main
request and there was a test against $r->is_main, but there's no
guarantee of that.

> What you are trying to do is probably :
> 
> $r->main->notes->set(__PACKAGE__ . '::SEEN', 1);
> 
> And then your check becomes
> 
> $r->main->notes->get(__PACKAGE__ . '::SEEN');
> 
> Without a need to cycle over the requests list either.

if that was the case, couldn't i just test against $r->is_main?

if you had to deal with this scenario, what would you do?

cheers

.d

Reply via email to