Hi all,

Is it possible to get $r->custom_response to respond using a MIME type other 
than text/html?

I’m writing a mod_perl application that’s intended to work with someone else’s 
React front end.  My code therefore just sends JSON.

For an authentication failure, I can use custom_response to send a custom JSON 
error with a Forbidden HTTP status:

        $r->custom_response(Apache2::Const::FORBIDDEN, $json);

It works fine, except that I can’t get it to use the correct MIME type.  The 
following has no effect (whether I deploy it immediately before the 
custom_response call or afterwards):

        $r->content_type("application/json; charset=utf-8”);

It’s not a huge deal — and I haven’t yet tested whether React freaks out over 
the Forbidden HTTP status regardless.

But if there’s a way to do this, I’d love to know.  Thanks!

Cheers,
Andrew.

-- 
Andrew Green
Article Seven Limited
http://www.article7.co.uk/ <http://www.article7.co.uk/>

Article Seven Limited is a registered company in England and Wales.  Registered 
number: 5703656. Registered office: 10 Hamilton Road, Sidcup, Kent, DA15 7HB.




Reply via email to