Michael wrote:
On Wed, Sep 03, 2003 at 09:42:00, Garrett Goebel said...


And gives the following recipe:
Example A-3. redirect_cookie.pl
use Apache::Constants qw(REDIRECT OK);
my $r = shift;
# prepare the cookie in $cookie
$r->err_headers_out->add('Set-Cookie' => $cookie);
$r->headers_out->set(Location => $location);
$r->status(REDIRECT);
$r->send_http_header;
return OK;
How would you have written it?
http://marc.theaimsgroup.com/?l=apache-modperl&m=106260380606735&w=2

thanks, I meant to put that in myself :)



Seems to me you'd want to *return* REDIRECT, not set $r->status to REDIRECT. Here's what I do in this case:

        $r->header_out(Location => $location);
        return REDIRECT;

I don't know if it's 100% correct, but it works quite well for me.

actually, the return value is entirely ignored in Registry scripts - that's why we need the $r->status hack, which is not needed (or desired) in handlers. if you returned SERVER_ERROR it would still work, so long as you set $r->status :)


however, yes, I prefer your way and return REDIRECT instead of OK - it just seems to make things that much closer to handler behavior, as well as being a bit more intuitive.

--Geoff



--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Reply via email to