Issues

ZF-11686: Zend_Controller_Action_Helper_Json doesn't send 'Content-Type: application/json' header

Description

The Action Helper returns Json encoded string but doesn't set the Content-Type Header.

Comments

Here is a patch which would solve this issue:


Index: library/Zend/Controller/Action/Helper/Json.php
===================================================================
--- library/Zend/Controller/Action/Helper/Json.php  (revision 24388)
+++ library/Zend/Controller/Action/Helper/Json.php  (working copy)
@@ -99,6 +99,7 @@
     {
         $data = $this->encodeJson($data, $keepLayouts);
         $response = $this->getResponse();
+        $response->setHeader('Content-Type', 'application/json', true);
         $response->setBody($data);
 
         if (!$this->suppressExit) {

@Marco The helper action Json uses view helper json where the header is assigned (see Zend_View_Helper_Json line 77).

Greetings Ramon

@Ramon: Thanks I see that it now works under 1.11.10. I had testet it with Zend Version 1.10.6 were the Header isn't overwritten in the view helper, thats because I only compared the Action Helper.

Bug can be closed

@Marco True this was fix in 1.11.1 with ZF-10675.