]> dev.renevier.net Git - syj.git/commitdiff
set charset in default content-type http header v0.3.2
authorarno <arno@renevier.net>
Mon, 18 Apr 2011 16:28:25 +0000 (18:28 +0200)
committerarno <arno@renevier.net>
Mon, 18 Apr 2011 16:28:25 +0000 (18:28 +0200)
application/configs/application.ini
application/controllers/helpers/SyjApi.php
application/controllers/plugins/SyjContentType.php [new file with mode: 0644]

index d80dbb3e004c56e967945350d35c3634e77e14f6..d3520cd368c423c427170039ad4fb4d53aa2ff19 100644 (file)
@@ -22,6 +22,7 @@ resources.frontController.defaultloc.maxlat = 70.0
 resources.frontController.actionhelperpaths.Syj_Controller_Action_Helper  = APPLICATION_PATH "/controllers/helpers"
 resources.frontController.plugins.locale = "Syj_Controllers_Plugins_SyjLocale"
 resources.frontController.plugins.loggeduser = "Syj_Controllers_Plugins_SyjLoggedUser"
+resources.frontController.plugins.contenttype = "Syj_Controllers_Plugins_SyjContentType"
 resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
 resources.db.adapter = "Pdo_Pgsql"
 ; i18n
index 92974c5ea775ecb3ab96ba29b7a7e491d5eb7e75..6016f99a75c6d76a8aa5a2102729396fad63ef89 100644 (file)
@@ -78,8 +78,8 @@ class Syj_Controller_Action_Helper_SyjApi extends Zend_Controller_Action_Helper_
     public function postDispatch() {
         $response = $this->getResponse();
 
-        $response->setHeader('Content-Type', $this->_contentType)
-                 ->setHeader('Content-Length', strlen($this->_body));
+        $response->setHeader('Content-Type', $this->_contentType, true)
+                 ->setHeader('Content-Length', strlen($this->_body), true);
 
         if ($this->_checkIfNoneMatch) {
             $request = $this->getRequest();
diff --git a/application/controllers/plugins/SyjContentType.php b/application/controllers/plugins/SyjContentType.php
new file mode 100644 (file)
index 0000000..782b0f2
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+/*  This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
+    and is published under the AGPL license. */
+
+class Syj_Controllers_Plugins_SyjContentType extends Zend_Controller_Plugin_Abstract
+{
+    public function preDispatch(Zend_Controller_Request_Abstract $request) {
+        // set default content-type
+        $response = Zend_Controller_Front::getInstance()->getResponse();
+        $response->setHeader('Content-Type', 'text/html; charset=utf-8', true);
+    }
+}