AW: Setting a MIME type on $r->custom_response

"Andreas Mock" <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
Hi Andrew,

 

have a look at 

 

$r->err_headers_out->add('Content-Type' => 'bla bla');

 

Best regards

Andreas

 

 

Von: Andrew Green <[email protected]> 
Gesendet: Dienstag, 24. September 2019 18:39
An: [email protected]
Betreff: Setting a MIME type on $r->custom_response

 

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/

Article Seven Limited is a registered company in England and Wales.  Registered number: 5703656. Registered office: 10 Hamilton Road, Sidcup, Kent, DA15 7HB.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.