clintonm9 has asked for the wisdom of the Perl Monks concerning the following question:

I am writing a RESTFul mod_perl program and having a hard time sending different http status codes back to the client. I am currently using the Apache2::Registry handler. I have tried many different wants to send back a different status code with no luck.
my($r) = shift; $r->status_line("401");
I have also tried with no luck:
return Apache2::Const::HTTP_UNAUTHORIZED;
&
return Apache2::Status::HTTP_UNAUTHORIZED;
Do i have to write my own handle to send back different error status?

Replies are listed 'Best First'.
Re: mod_perl and http status codes
by jdrago999 (Pilgrim) on Mar 04, 2010 at 23:44 UTC

    Works like this:

    package My::Handler; use strict; use warnings 'all'; use Apache2::RequestRec; sub handler : method { my ($class, $r) = @_; $r->status( 401 ); return 401; } 1;# return true:
      Thank you that worked!