You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Martin Moss <ma...@btopenworld.com> on 2005/11/01 15:31:33 UTC

is_intial_req

I'm a little confused. And was wondering if I could
get a sanity check..

I have a mod perl method handler and at start it runs
this code

my $is_initial_req = $r->is_initial_req;
    my $is_main = $r->is_main;
    my $main = $r->main;
    my $proxyreq = $r->proxyreq;

    print STDERR
Dumper('is_initial_req',$is_initial_req,'is_main',$is_main,'main',$main,'proxyreq',$proxyreq)
if $DEBUG;

I am running a system which has embperl installed
using this:-

<FilesMatch "epl$|wml$|pgp$|html$">
  SetHandler  perl-script
  PerlHandler Embperl
  Options     ExecCGI FollowSymLinks
</FilesMatch>

And My handler is called using this

<Location /logout>
    setHandler perl-script
    PerlModule My::Apache::Authen::Cookie
    PerlHandler My::Apache::Authen::Cookie->logout
</Location>

I also have a second 'control' instance of this
handler installed purely for this debugging

<Location /logout2>
    setHandler perl-script
    PerlModule My::Apache::Authen::Cookie
    PerlHandler My::Apache::Authen::Cookie->logout
</Location>

Finally there is a directory under my document root
called /logout/ which contains old Embperl scripts I'm
superceding with my handler (so would be found on a
FilesMatch).

The question I have is this.:-

When I visit /logout I get the following Dumped
information from my handler:-

$VAR1 = 'is_initial_req';
$VAR2 = '0';
$VAR3 = 'is_main';
$VAR4 = 1;
$VAR5 = 'main';
$VAR6 = undef;
$VAR7 = 'proxyreq';
$VAR8 = '0';

But when I visit /logout2 I get the following:-

$VAR1 = 'is_initial_req';
$VAR2 = 1;
$VAR3 = 'is_main';
$VAR4 = 1;
$VAR5 = 'main';
$VAR6 = undef;
$VAR7 = 'proxyreq';
$VAR8 = '0';

Why is is_initial_req consistently 0 for logout and
consistently 1 for logout2...

I tried swapping the order of the FilesMatch and the
Location configs in my httpd.conf but this made no
difference...

So can anybody clear up this mystery for me?

Kind regards

Marty



		
___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

Re: is_intial_req

Posted by Kevin Bosak <ph...@gmail.com>.
Try looking at the url that your handler is called with. It's likely that
since you have a directory with that name and presumably 'index.html' in
that directory then mod_dir performs an internal redirect with 'index.html'
appended to the url.

On 11/1/05, Martin Moss <ma...@btopenworld.com> wrote:
>
> I had a quick look at this and found both my requests
> to /logout/ and /logout2/ typed into the browser
> manually, continue to result in the same issue..
>
> Here's the rewrite rules I have on my https proxy that
> each request comes through..
>
> RewriteRule ^/logout/(.*)$
> http://${farm:map_pf}/logout/$1 [P,L]
> RewriteRule ^/logout2/(.*)$
> http://${farm:map_pf}/logout2/$1 [P,L]
>
> I also ammended both locations to use
> /logout/ and /logout2/
>
> And I still get the same issue...(so as far as I'm
> aware no further internal translation is made..)
>
> --- Geoffrey Young <ge...@modperlcookbook.org> wrote:
>
> >
> > > Why is is_initial_req consistently 0 for logout
> > and
> > > consistently 1 for logout2...
> >
> > besides the existing conversation, you need to
> > remember what is_initial_req
> > means - it means that this is the request as it came
> > straight from the
> > browser and wasn't redirected at all. if apache
> > made an internal redirect
> > from /logout to /logout/ that would make
> > is_initial_req false.
> >
> > so, try playing around with trailing slashes and
> > making sure that your
> > requests are in fact equivalent (that you're not
> > asking for /logout one time
> > and /logout/index.html the next, for example).
> >
> > HTH
> >
> > --Geoff
> >
>
>
>
>
> ___________________________________________________________
> How much free photo storage do you get? Store your holiday
> snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
>

Re: is_intial_req

Posted by Martin Moss <ma...@btopenworld.com>.
I had a quick look at this and found both my requests
to /logout/ and /logout2/ typed into the browser
manually, continue to result in the same issue..

Here's the rewrite rules I have on my https proxy that
each request comes through..

RewriteRule ^/logout/(.*)$
http://${farm:map_pf}/logout/$1 [P,L]
RewriteRule ^/logout2/(.*)$
http://${farm:map_pf}/logout2/$1 [P,L]

I also ammended both locations to use 
/logout/ and /logout2/

And I still get the same issue...(so as far as I'm
aware no further internal translation is made..)

--- Geoffrey Young <ge...@modperlcookbook.org> wrote:

> 
> > Why is is_initial_req consistently 0 for logout
> and
> > consistently 1 for logout2...
> 
> besides the existing conversation, you need to
> remember what is_initial_req
> means - it means that this is the request as it came
> straight from the
> browser and wasn't redirected at all.  if apache
> made an internal redirect
> from /logout to /logout/ that would make
> is_initial_req false.
> 
> so, try playing around with trailing slashes and
> making sure that your
> requests are in fact equivalent (that you're not
> asking for /logout one time
> and /logout/index.html the next, for example).
> 
> HTH
> 
> --Geoff
> 



		
___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

Re: is_intial_req

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> Why is is_initial_req consistently 0 for logout and
> consistently 1 for logout2...

besides the existing conversation, you need to remember what is_initial_req
means - it means that this is the request as it came straight from the
browser and wasn't redirected at all.  if apache made an internal redirect
from /logout to /logout/ that would make is_initial_req false.

so, try playing around with trailing slashes and making sure that your
requests are in fact equivalent (that you're not asking for /logout one time
and /logout/index.html the next, for example).

HTH

--Geoff

RE: is_intial_req

Posted by Gerald Richter <ri...@ecos.de>.
> 
> Is it possible Embperl does something with the Apache Request 
> in an earlier Phase of the request?
> 

No, Embperl does step in at the content phase, but never before

Gerald



 
** Virus checked by BB-5000 Mailfilter ** 


Re: is_intial_req

Posted by Martin Moss <ma...@btopenworld.com>.
Hi Micheal..

It's a sticky one, because surely that would
definitely mean that the Location would take
precedence and the FilesMatch would be secondary...
And I am seeing this, my handler does get run first...
But it is Never the initial Request... 

Obviously something is happenning, behind the scenes,
and I can't work it out...

Is it possible Embperl does something with the Apache
Request in an earlier Phase of the request?


--- Michael Peters <mp...@plusthree.com> wrote:

> 
> 
> Martin Moss wrote:
> > I'm a little confused. And was wondering if I
> could
> > get a sanity check..
> 
> > I tried swapping the order of the FilesMatch and
> the
> > Location configs in my httpd.conf but this made no
> > difference...
> 
> From reading
> http://httpd.apache.org/docs/1.3/sections.html, it
> seems
> that Location will always take precedence over
> FilesMatch regardless of
> their order.
> 
> Order only matters in the precedence of similar
> tags.
> 
> -- 
> Michael Peters
> Developer
> Plus Three, LP
> 
> 



		
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

Re: is_intial_req

Posted by Michael Peters <mp...@plusthree.com>.

Martin Moss wrote:
> I'm a little confused. And was wondering if I could
> get a sanity check..

> I tried swapping the order of the FilesMatch and the
> Location configs in my httpd.conf but this made no
> difference...

>From reading http://httpd.apache.org/docs/1.3/sections.html, it seems
that Location will always take precedence over FilesMatch regardless of
their order.

Order only matters in the precedence of similar tags.

-- 
Michael Peters
Developer
Plus Three, LP


Re: is_intial_req

Posted by Martin Moss <ma...@btopenworld.com>.
yeah you're right, it does, thats what I've been
doing. But I'm having to use a rewrite rule to ensure
I don't have to go and manually edit the silly amount
of hardcoded links to /logout I've inherited with the
old code...:-(

Just bugs me that I don't understand the details of
why..

Marty


--- Frank Wiles <fr...@wiles.org> wrote:

> On Tue, 1 Nov 2005 14:54:31 +0000 (GMT)
> Martin Moss <ma...@btopenworld.com> wrote:
> 
> > Hey Frank..
> > 
> > I agree, thats why I setup the logout2 control
> test.
> > What I don't understand is "why" it is tripping it
> > out. Surely it would only trip it out if the order
> of
> > the httpd.conf filesmatch and location is set one
> way
> > around, and then not trip it out if the order is
> > reversed, not both as I'm seeing...
> 
>   Order has almost no meaning in Apache's config
> files.  It's all
>   about the depth of the "nesting" of directives. 
> Much like CSS. 
> 
>   I don't have a really great explanation as to the
> cause, as I've
>   never used embedperl.  But I would think it would
> make your life
>   easier if you just didn't put handlers on
> Locations that also have
>   Embedperl scripts on the filesystem.  For
> clarity/readability as
>   much as to avoid this bug. 
> 
>  ---------------------------------
>    Frank Wiles <fr...@wiles.org>
>    http://www.wiles.org
>  ---------------------------------
> 
> 



		
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

Re: is_intial_req

Posted by Frank Wiles <fr...@wiles.org>.
On Tue, 1 Nov 2005 14:54:31 +0000 (GMT)
Martin Moss <ma...@btopenworld.com> wrote:

> Hey Frank..
> 
> I agree, thats why I setup the logout2 control test.
> What I don't understand is "why" it is tripping it
> out. Surely it would only trip it out if the order of
> the httpd.conf filesmatch and location is set one way
> around, and then not trip it out if the order is
> reversed, not both as I'm seeing...

  Order has almost no meaning in Apache's config files.  It's all
  about the depth of the "nesting" of directives.  Much like CSS. 

  I don't have a really great explanation as to the cause, as I've
  never used embedperl.  But I would think it would make your life
  easier if you just didn't put handlers on Locations that also have
  Embedperl scripts on the filesystem.  For clarity/readability as
  much as to avoid this bug. 

 ---------------------------------
   Frank Wiles <fr...@wiles.org>
   http://www.wiles.org
 ---------------------------------


Re: is_intial_req

Posted by Martin Moss <ma...@btopenworld.com>.
Hey Frank..

I agree, thats why I setup the logout2 control test.
What I don't understand is "why" it is tripping it
out. Surely it would only trip it out if the order of
the httpd.conf filesmatch and location is set one way
around, and then not trip it out if the order is
reversed, not both as I'm seeing...

Would this also mean that once my ContentHandler has
returned OK, and sent Data back to the user and
"finished" as far as I'm concerned, that the Apache
server is then going off and running the old logout
embperl scripts too?

If so, how do I tell apache that I don't wish any more
contentHandlers to be run?

I posted an issue a while back about trying to use
push_handlers and set_handlers... and push_handlers
works, but set_handlers doesn't... never got a
solution, beyond what I'd already tried.. All very
weird..... 

Marty

--- Frank Wiles <fr...@wiles.org> wrote:

> On Tue, 1 Nov 2005 14:31:33 +0000 (GMT)
> Martin Moss <ma...@btopenworld.com> wrote:
> 
> > I'm a little confused. And was wondering if I
> could
> > get a sanity check..
> > 
> > I have a mod perl method handler and at start it
> runs
> > this code
> > 
> > my $is_initial_req = $r->is_initial_req;
> >     my $is_main = $r->is_main;
> >     my $main = $r->main;
> >     my $proxyreq = $r->proxyreq;
> > 
> >     print STDERR
> >
>
Dumper('is_initial_req',$is_initial_req,'is_main',$is_main,'main',
> > $main,'proxyreq',$proxyreq) if $DEBUG;
> > 
> > I am running a system which has embperl installed
> >
> > Why is is_initial_req consistently 0 for logout
> and
> > consistently 1 for logout2...
> > 
> > I tried swapping the order of the FilesMatch and
> the
> > Location configs in my httpd.conf but this made no
> > difference...
> > 
> > So can anybody clear up this mystery for me?
> 
>   I think your FilesMatch is what is tripping you
> up.  As a test,
>   move /logout/ to /logout3/ and see if you then get
> the same results
>   as /logout2/.  
> 
>  ---------------------------------
>    Frank Wiles <fr...@wiles.org>
>    http://www.wiles.org
>  ---------------------------------
> 
> 



		
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

Re: is_intial_req

Posted by Frank Wiles <fr...@wiles.org>.
On Tue, 1 Nov 2005 14:31:33 +0000 (GMT)
Martin Moss <ma...@btopenworld.com> wrote:

> I'm a little confused. And was wondering if I could
> get a sanity check..
> 
> I have a mod perl method handler and at start it runs
> this code
> 
> my $is_initial_req = $r->is_initial_req;
>     my $is_main = $r->is_main;
>     my $main = $r->main;
>     my $proxyreq = $r->proxyreq;
> 
>     print STDERR
> Dumper('is_initial_req',$is_initial_req,'is_main',$is_main,'main',
> $main,'proxyreq',$proxyreq) if $DEBUG;
> 
> I am running a system which has embperl installed
>
> Why is is_initial_req consistently 0 for logout and
> consistently 1 for logout2...
> 
> I tried swapping the order of the FilesMatch and the
> Location configs in my httpd.conf but this made no
> difference...
> 
> So can anybody clear up this mystery for me?

  I think your FilesMatch is what is tripping you up.  As a test,
  move /logout/ to /logout3/ and see if you then get the same results
  as /logout2/.  

 ---------------------------------
   Frank Wiles <fr...@wiles.org>
   http://www.wiles.org
 ---------------------------------