CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Status codes on PerlResponseHandler


New User

Oct 28, 2009, 8:09 AM

Post #1 of 2 (293 views)
Status codes on PerlResponseHandler Can't Post

Hi Folks,

I'm trying to set an HTTP status code on a mod_perl handler to something other than 200. The following handler method does not, despite my best efforts, produce anything other than a 200:

sub handler 
my $request = shift;

# do some stuff


return Apache2::Const::HTTP_CREATED;

The documentation is a bit unclear as to what to do, and I can't think of any other way that I might be able to affect the status code.

Any thoughts welcome,



New User

Oct 29, 2009, 4:56 AM

Post #2 of 2 (281 views)
Re: [RichardJones] Status codes on PerlResponseHandler [In reply to] Can't Post

For anyone that cares, the cause of this problem is that if the

# do some stuff

bit includes any "print" statements to STDOUT, anywhere at all in the stack of subsequently executed code, then the response handler sends a 200 header to the browser long before it flushes the request object and its actually desired header back to the client.

So if you have, for example, a logger which logs to STDOUT under certain conditions, it will break your website.

Seems like a bug to me.



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives