Add RawDisplayHandler and fix RSS/Atom not producing the correct headers

This commit is contained in:
Kijin Sung 2020-12-13 22:06:16 +09:00
parent 35203b684d
commit a405b91e42
5 changed files with 49 additions and 4 deletions

View file

@ -52,6 +52,10 @@ class DisplayHandler extends Handler
$this->gz_enabled = FALSE;
}
}
elseif(Context::getResponseMethod() == 'RAW')
{
$handler = new RawDisplayHandler();
}
else
{
$handler = new HTMLDisplayHandler();
@ -114,6 +118,10 @@ class DisplayHandler extends Handler
{
self::_printXMLHeader();
}
elseif(Context::getResponseMethod() == 'RAW' && $content_type = Context::get('response_content_type'))
{
self::_printCustomContentTypeHeader($content_type);
}
else
{
self::_printHTMLHeader();
@ -329,6 +337,18 @@ class DisplayHandler extends Handler
{
header("Content-Type: application/json; charset=UTF-8");
}
/**
* print a custom Content-Type header.
*
* @param string $content_type
* @return void
*/
public static function _printCustomContentTypeHeader($content_type)
{
$charset = (strpos($content_type, 'text/') === 0) ? '; charset=UTF-8' : '';
header('Content-Type: ' . $content_type . $charset);
}
/**
* print a HTTP HEADER for HTML, which is encoded in UTF-8

View file

@ -0,0 +1,20 @@
<?php
class RawDisplayHandler
{
function toDoc($oModule)
{
$tpl_path = $oModule->getTemplatePath();
$tpl_file = $oModule->getTemplateFile();
if ($tpl_path && $tpl_file)
{
$oTemplate = TemplateHandler::getInstance();
$output = $oTemplate->compile($tpl_path, $tpl_file);
}
else
{
$output = '';
}
return $output;
}
}