You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Helmut Zeilinger <hz...@hzlabs.de> on 2004/05/01 13:12:15 UTC

$r->status() ?

Hi all,

i am confused about $r->status().
When do i have to set this "manually" - if ever? 
I searched for documentations about this item, but i did not find a
detailed explaination.

My problem is, what's the difference between

sub handler {
..
$r->status(404);
return (?);
}

and

sub handler {
..
return (HTTP_NOT_FOUND);
}

[? means that i don't know what to return]


Regards

Helmut

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: $r->status() ?

Posted by Helmut Zeilinger <hz...@hzlabs.de>.
Yes helped .. thanks a lot for explaining this again!

Helmut

--On Saturday, May 01, 2004 09:41:13 -0400 Geoffrey Young
<ge...@modperlcookbook.org> wrote:

> 
> 
> Helmut Zeilinger wrote:
>> Hi all,
>> 
>> i am confused about $r->status().
>> When do i have to set this "manually" - if ever?
> 
> you should never set $r->status from a handler.
> 
>> I searched for documentations about this item, but i did not find a
>> detailed explaination.
> 
> I've explained it on this and the dev list a few times, so you should find
> discussions in the archives.  it's also in the mod_perl developer's
> cookbook.
> 
>> 
>> My problem is, what's the difference between
>> 
>> sub handler {
>> ..
>> $r->status(404);
>> return (?);
>> }
> 
> that idiom is used with Registry scripts and Registry scripts only.  it's
> basically a hack that let's Registry scripts return something other than
> ok.  note that Registry sets $r->handler back to whatever it was before
> you messed with it, and it is the only valid use of $r->status($foo).
> 
>> 
>> and
>> 
>> sub handler {
>> ..
>> return (HTTP_NOT_FOUND);
>> }
>> 
>> [? means that i don't know what to return]
> 
> the return value of the handler is the status that gets set on the HTTP
> Response Line.  $r->status is really an internal bookeeping variable for
> apache - most of the time it's the same as the response line status, but
> if you set it manually it will mess up any future error document cycles,
> since that's the marker that apache uses for keeping track of recursive
> errors (the "additionally, a 500 server error was encountered" foo).
> 
> again, you can search the archives and MPDC for more details.
> 
> HTH
> 
> --Geoff
>  


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: $r->status() ?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Helmut Zeilinger wrote:
> Hi all,
> 
> i am confused about $r->status().
> When do i have to set this "manually" - if ever?

you should never set $r->status from a handler.

> I searched for documentations about this item, but i did not find a
> detailed explaination.

I've explained it on this and the dev list a few times, so you should find
discussions in the archives.  it's also in the mod_perl developer's cookbook.

> 
> My problem is, what's the difference between
> 
> sub handler {
> ..
> $r->status(404);
> return (?);
> }

that idiom is used with Registry scripts and Registry scripts only.  it's
basically a hack that let's Registry scripts return something other than ok.
 note that Registry sets $r->handler back to whatever it was before you
messed with it, and it is the only valid use of $r->status($foo).

> 
> and
> 
> sub handler {
> ..
> return (HTTP_NOT_FOUND);
> }
> 
> [? means that i don't know what to return]

the return value of the handler is the status that gets set on the HTTP
Response Line.  $r->status is really an internal bookeeping variable for
apache - most of the time it's the same as the response line status, but if
you set it manually it will mess up any future error document cycles, since
that's the marker that apache uses for keeping track of recursive errors
(the "additionally, a 500 server error was encountered" foo).

again, you can search the archives and MPDC for more details.

HTH

--Geoff

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html