-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move content-type setting to controller plugin.
This tries harder to avoid any duplicate setting of the content-type header, which breaks fastcgi setups.
- Loading branch information
1 parent
842bf1e
commit 4ccdb3d
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
application/libraries/Omeka/Controller/Plugin/DefaultContentType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* Omeka | ||
* | ||
* @copyright Copyright 2007-2012 Roy Rosenzweig Center for History and New Media | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GNU GPLv3 | ||
*/ | ||
|
||
/** | ||
* This controller plugin sets the default Content-Type header when one hasn't | ||
* been set at the end of the controller processing. | ||
* | ||
* This has to be done here because Zend allows header duplication, the | ||
* output contexts don't overwrite headers of the same name, and some servers | ||
* (FastCGI) choke when they see two Content-Type headers. | ||
*/ | ||
class Omeka_Controller_Plugin_DefaultContentType extends Zend_Controller_Plugin_Abstract | ||
{ | ||
/** | ||
* Add a default Content-Type to the response if none is already set. | ||
*/ | ||
public function dispatchLoopShutdown() | ||
{ | ||
$response = $this->getResponse(); | ||
|
||
$typeAlreadySet = false; | ||
foreach ($response->getHeaders() as $header) { | ||
if ($header['name'] == 'Content-Type') { | ||
$typeAlreadySet = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!$typeAlreadySet) { | ||
$response->setHeader('Content-Type', 'text/html; charset=utf-8'); | ||
} | ||
} | ||
} |