Gunnar Wolf skrev:
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!
:-)
Do You have to call exit() at all? If You just finnish your code with
the redirection statement? I do so in my app where the redirection is
the last statement of execution.
/Oskar Ahner
[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>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
</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 ;-)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]