how to return 204 response code in mod perl

369 Views Asked by At

I have web service written using mod_perl hosted on apache httpd. In handler I am returning, but I am getting 200 response code. I am not setting anything in response body.

sub handler {
    return Apache2::Const::HTTP_NO_CONTENT;
}

Curl is giving me 200 response code

HTTP/1.1 200 OK
Date: Fri, 10 Jan 2014 09:32:26 GMT
Server: Apache
Content-Length: 0
Connection: close
Content-Type: text/plain
1

There are 1 best solutions below

0
On BEST ANSWER

You can explicitly set the response code that you want to return using the following

$r->status(Apache2::Const::HTTP_NO_CONTENT); $r->rflush;

This will override whatever you return from the handler function.