Gerald Richter dijo [Wed, Dec 13, 2006 at 08:02:26AM +0100]:
> In your module, you should call Embperl::exit (301) instead of just exit,
> because calling exit only, will terminate the whole Apache child, which is
> not what you want.

Ok, changed to Embperl::Exit - Now I get yet another message logged!
:-) 

[Wed Dec 13 19:25:24 2006] [error] [3823]ERR:  24:  Error in Perl code: request 
301 at 
/home/gwolf/cvs/iiec_minisist/SmbGate/trunk/lib//SmbGate/Embperl/WebClient.pm 
line 48.\n

It happens when called from here (in base.pm):

    # Sorry, ma'am. No valid user no play.
    unless ($epreq->{smb}->is_logged_in or 
        $epreq->param->filename =~ m!/(?:doc/\w*|login)\.html$!) {
        $epreq->{webclient}->redirect('login.html');
    }

> The main problem will be, that this will exit the whole request and you
> didn't have set the headers for redirect so far
> 
> So the question is where do you set your http headers?

Humh... Strangely, it works! ;-) Using netcat:

-----------------8<------------------8<------------------8<-----------------
$ nc mosca 80
GET /smb/should_be_redirected HTTP/1.1
host: mosca

HTTP/1.1 301 Moved Permanently
Date: Wed, 13 Dec 2006 19:33:38 GMT
Server: Embperl/2.0rc3 Apache/2.0.54 (Debian GNU/Linux) PHP/4.3.10-18 
mod_perl/1.999.21 Perl/v5.8.4
Content-Length: 935
Location: /smb/login.html
Set-Cookie: EMBPERL_UID=7d9ea34f777e084574b6a8a2f357934b
Content-Type: text/html; charset=UTF-8

<HTML><HEAD><TITLE>Embperl Error</TITLE></HEAD><BODY bgcolor="#FFFFFF">
<H1>Internal Server Error</H1>
The server encountered an internal error or misconfiguration and was unable to 
complete your request.<P>
Please contact the server administrator, [EMAIL PROTECTED] and inform them of 
the time the error occurred, and anything you might have done that may have 
caused the error.<P><P>
<table cellspacing='2' cellpadding='5'>
<tr bgcolor='#eeeeee'><td>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
[3823]ERR:  24:  Error in Perl code: request 301 at 
/home/gwolf/cvs/iiec_minisist/SmbGate/trunk/lib//SmbGate/Embperl/WebClient.pm 
line 48.
<br>&nbsp;&nbsp;&nbsp;&nbsp;
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
</td></tr>
</table>
<br>
Embperl/2.0rc3 Apache/2.0.54 (Debian GNU/Linux) PHP/4.3.10-18 mod_perl/1.999.21 
Perl/v5.8.4 [Wed Dec 13 19:33:41 2006]<P>
</BODY></HTML>
-----------------8<------------------8<------------------8<-----------------

Of course, the user never sees this error, as the redirection gets
correctly sent. But still, the logs get cluttered, and... Well, this
should not happen(mr)! Anyway, what's the flow that gets me to this
redirect? 

1- SmbGate::Embperl::WebClient is instantiated with references to the
   Embperl structures it deals with:
   $epreq->{webclient} = SmbGate::Embperl::WebClient->new($epreq, 
\%http_headers_out, \%udat);
2- In base.pm's init, every request is checked to verify if it contains
   proper authentication credentials (or if it is targetted to a public
   page) with the snippet I posted above.
3- WebClient's redirect sets $http_headers_out{Location} to the
   destination URL and exits with 301 (HTTP redirect). Somehow (don't
   ask me, you are the guy who worte it ;-) ), the 'exit' happens only
   after sending the correct headers

So... It is a matter of niceity and correctness, not of brokenness :)

> > You will notice I'm using $epreq to hold my various objects 
> > so they are available along the way - I lack a better way of 
> > doing this, you might also point me out to another way of 
> > doing this :)
> 
> $epreq is a perfect place for storing such things

Good, I'm more at ease with this ;-)

-- 
Gunnar Wolf - [EMAIL PROTECTED] - (+52-55)5623-0154 / 1451-2244
PGP key 1024D/8BB527AF 2001-10-23
Fingerprint: 0C79 D2D1 2C4E 9CE4 5973  F800 D80E F35A 8BB5 27AF

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to