You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Colin Wetherbee <cw...@denterprises.org> on 2007/12/22 17:29:32 UTC

Re: Find the values of Apache2::Const

Boysenberry Payne wrote:
> I found that $r->status() required something other than Apache2::Const
> in one of my modules and it got me wondering what the Constant values
> actually were.  Now I could go through and print each one I suppose, but I
> thought looking at them in Apache2::Const.pm would be better, but the
> package seems to be mostly pod notation.  How can I look up the constants,
> i.e. where are they?

This isn't exactly a "list" of them, but it might point you in the right 
direction.  They're buried pretty well, it seems.

http://stuff.mit.edu/afs/sipb/service/httpd/src/mod_perl-2.0.1/src/modules/perl/modperl_constants.c

(Also <http://tinyurl.com/32y54e>)

Colin

Re: Find the values of Apache2::Const

Posted by Colin Wetherbee <cw...@denterprises.org>.
Adam Prime wrote:
> Boysenberry Payne wrote:
>> I only ask because I tried a $r->status(Apache2::Const::OK) and got
>> a 500 returned in the header even though my handler returned with
>> Apache::Const::OK also...
>> 
>> To avoid the 500 header I had to do $r->status(200);  I imagine the
>>  status code isn't going to change too soon, so I ought to be okay,
>> right?
> 
> I believe in this situation what you want is 
> $r->status(Apache::Const::HTTP_OK).  HTTP_OK and OK are not the same
>  thing at all.

Good point.  I guess I wasn't reading the original post clearly enough. 
  That would certainly make a difference.

Colin

Re: Find the values of Apache2::Const

Posted by Jonathan Vanasco <jv...@2xlp.com>.
On Dec 22, 2007, at 11:53 AM, Adam Prime wrote:
>> I believe in this situation what you want is $r->status 
>> (Apache::Const::HTTP_OK).  HTTP_OK and OK are not the same thing  
>> at all.

It's a mean trick...  one is an HTTP constant, the other is a  
mod_perl constant ( ie HTTP_ prefix and no prefix )

not having the codes in the docs is annoying too - we argued about  
this in august 06 , and Fred Moyer was excellent enough to create a  
patch to the MP source to fix this

		Subject: 	Re: status codes in Apache2::Const ?
		From: 	  fred@taperfriendlymusic.org
		Date: 	September 2, 2006 2:45:36 AM EDT

oddly ( i never realized this before ) the patch is not in  
Apache2::Const, but in

	http://perl.apache.org/docs/2.0/user/handlers/ 
http.html#HTTP_Status_Codes

we should probably link the Apache2::Const docs to the new handlers  
doc section

Re: Find the values of Apache2::Const

Posted by Adam Prime <ad...@utoronto.ca>.
Boysenberry Payne wrote:
> I only ask because I tried a $r->status(Apache2::Const::OK) and got a 
> 500 returned in the header
> even though my handler returned with Apache::Const::OK also...
> 
> To avoid the 500 header I had to do $r->status(200);  I imagine the 
> status code isn't going to change
> too soon, so I ought to be okay, right?

I believe in this situation what you want is 
$r->status(Apache::Const::HTTP_OK).  HTTP_OK and OK are not the same 
thing at all.

>> This isn't exactly a "list" of them, but it might point you in the 
>> right direction.  They're buried pretty well, it seems.
> 
> Yeah, I figured it was in c, I stopped at the XSLoader.pm package....
> 
> Thanks,
> Boysenberry
> 

Re: Find the values of Apache2::Const

Posted by Boysenberry Payne <bo...@habitatlife.com>.
When you print Apache2::Const::OK do you get 200?

I'm including it using:
use Apache2::Const -compile => qw( OK REDIRECT FORBIDDEN  
REMOTE_DOUBLE_REV );

I get 0.  I get the correct codes for others like FORBIDDEN, etc.  Go  
figure...

I think what I should have used was HTTP_OK, that seems to return 200...


-bop

On Dec 22, 2007, at 10:45 AM, Colin Wetherbee wrote:

> Boysenberry Payne wrote:
>> I only ask because I tried a $r->status(Apache2::Const::OK) and got a
>>  500 returned in the header even though my handler returned with
>> Apache::Const::OK also...
>> To avoid the 500 header I had to do $r->status(200);  I imagine  
>> the status code isn't going to change too soon, so I ought to be  
>> okay,
>> right?
>
> The HTTP/1.1 status codes are defined in RFC 2616 [0], section  
> 6.1.1.  I doubt they will change any time soon, so it should be  
> fine to use the numbers.
>
> However, if your constants aren't working like they should, it's  
> probably worth figuring out why.
>
> I always include my constants with the following line.  Deviating  
> from this specific syntax always seems to break stuff for me.
>
> use Apache2::Const -compile => qw(:common);
>
> Colin
>
> [0] http://www.faqs.org/rfcs/rfc2616.html


Re: Find the values of Apache2::Const

Posted by Colin Wetherbee <cw...@denterprises.org>.
Boysenberry Payne wrote:
> I only ask because I tried a $r->status(Apache2::Const::OK) and got a
>  500 returned in the header even though my handler returned with
> Apache::Const::OK also...
> 
> To avoid the 500 header I had to do $r->status(200);  I imagine the 
> status code isn't going to change too soon, so I ought to be okay,
> right?

The HTTP/1.1 status codes are defined in RFC 2616 [0], section 6.1.1.  I 
doubt they will change any time soon, so it should be fine to use the 
numbers.

However, if your constants aren't working like they should, it's 
probably worth figuring out why.

I always include my constants with the following line.  Deviating from 
this specific syntax always seems to break stuff for me.

use Apache2::Const -compile => qw(:common);

Colin

[0] http://www.faqs.org/rfcs/rfc2616.html

Re: Find the values of Apache2::Const

Posted by Boysenberry Payne <bo...@habitatlife.com>.
I only ask because I tried a $r->status(Apache2::Const::OK) and got a  
500 returned in the header
even though my handler returned with Apache::Const::OK also...

To avoid the 500 header I had to do $r->status(200);  I imagine the  
status code isn't going to change
too soon, so I ought to be okay, right?

> This isn't exactly a "list" of them, but it might point you in the  
> right direction.  They're buried pretty well, it seems.

Yeah, I figured it was in c, I stopped at the XSLoader.pm package....

Thanks,
Boysenberry


On Dec 22, 2007, at 10:29 AM, Colin Wetherbee wrote:

> Boysenberry Payne wrote:
>> I found that $r->status() required something other than  
>> Apache2::Const
>> in one of my modules and it got me wondering what the Constant values
>> actually were.  Now I could go through and print each one I  
>> suppose, but I
>> thought looking at them in Apache2::Const.pm would be better, but the
>> package seems to be mostly pod notation.  How can I look up the  
>> constants,
>> i.e. where are they?
>
> This isn't exactly a "list" of them, but it might point you in the  
> right direction.  They're buried pretty well, it seems.
>
> http://stuff.mit.edu/afs/sipb/service/httpd/src/mod_perl-2.0.1/src/ 
> modules/perl/modperl_constants.c
>
> (Also <http://tinyurl.com/32y54e>)
>
> Colin