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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



RichardJones
New User

Oct 28, 2009, 8:09 AM

Post #1 of 2 (292 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:


Code
sub handler 
{
my $request = shift;

# do some stuff

request->status(201);

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,

Regards

Richard


RichardJones
New User

Oct 29, 2009, 4:56 AM

Post #2 of 2 (280 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


Code
# 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.

R

 
 


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

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