perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <torsten.foert...@gmx.net>
Subject Re: [mp2] $req->main->is_initial_req == 0 ???
Date Tue, 04 Apr 2006 07:45:33 GMT
On Monday 03 April 2006 23:18, Michael McLagan wrote:
>     "Main" to me says the one that was received by the server over the
>     internet -- from the client -- ie no matter how many requests deep
>     we are at any given point, main() always returns the top most item
>     on the pile.  In that case, checking main->is_initial_request should
>     always be 1 and looking at the uri() should always be what the server
>     got from the client.

Unfortunately, it is not that simple. is_initial_req() is implemented as

  !$r->main && !$r->prev

If $r->prev is true then $r is the result of an internal redirect (created for 
example by $r->internal_redirect). If $r->main is true then $r is a 
subrequest (created for example by $r->lookup_uri or $r->lookup_file).

For the initial request both conditions must be false.

>     If that's the correct interpretation of what the documentation says,
>     then I suspect there's a problem within the code as outlined in the
>     message subject -- main() isn't really main!
>
>     I found this particular discrepancy with a structure similar to the
>     following:
>
>     /file1.html:
>
>       <BODY>
>       <!--#include virtual="/file2.html" -->
>       </BODY>

This creates a subrequest.

>     /file2.html
>
>        <BODY>
>        <!--#include virtual="/bin/form" -->
>        </BODY>

and this another one, a subrequest of the subrequest.

[...]

>        <!-- is_initial 0 -->
>        <!-- uri /bin/form -->
>        <!-- main->is_initial 0 -->
>        <!-- main->uri /file2.html -->
>        <!-- main->main->is_initial 1 -->
>        <!-- main->main->uri /file1.html -->
>        <!-- req->uri /file1.html -->

And what you see is exactly that request chain.

Try your /file1.html as an ErrorDocument to see what happens when internal 
redirects pop up. Or try this CGI script. It generates an internal redirect 
as well:

  print "Status: 200\nLocation: /file1.html\n\n";

Torsten

Mime
View raw message