Core update (better response handling)

This commit is contained in:
markseu 2015-02-02 14:39:53 +01:00
parent 06c837bdae
commit 52a9db7a44
2 changed files with 11 additions and 11 deletions

View file

@ -1,4 +1,4 @@
Yellow 0.4.24
Yellow 0.4.25
=============
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/markseu/yellowcms)

View file

@ -5,7 +5,7 @@
// Yellow main class
class Yellow
{
const Version = "0.4.24";
const Version = "0.4.25";
var $page; //current page
var $pages; //pages from file system
var $config; //configuration
@ -185,14 +185,6 @@ class Yellow
$statusCode = 304;
$this->page->clean($statusCode);
}
if($statusCode==200 && $this->getRequestHandler()=="core" && $this->page->isExisting("redirect"))
{
$statusCode = 301;
$location = $this->toolbox->normaliseLocation($this->page->get("redirect"), $this->page->base, $this->page->location);
$locationHeader = $this->toolbox->getLocationHeader($this->page->serverScheme, $this->page->serverName, "", $location);
$this->page->clean($statusCode, $locationHeader);
$this->page->setHeader("Cache-Control", "no-cache, must-revalidate");
}
if($this->page->isExisting("pageClean")) ob_clean();
if(PHP_SAPI != "cli")
{
@ -586,10 +578,18 @@ class YellowPage
{
$this->error(500, "Parser '".$this->get("parser")."' does not exist!");
}
if(!$this->yellow->toolbox->isValidContentType($this->getHeader("Content-Type"), $this->getLocation()))
if($this->statusCode==200 && $this->yellow->getRequestHandler()=="core" &&
!$this->yellow->toolbox->isValidContentType($this->getHeader("Content-Type"), $this->getLocation()))
{
$this->error(500, "Type '".$this->getHeader("Content-Type")."' does not match file name!");
}
if($this->statusCode==200 && $this->yellow->getRequestHandler()=="core" && $this->isExisting("redirect"))
{
$location = $this->yellow->toolbox->normaliseLocation($this->get("redirect"), $this->base, $this->location);
$locationHeader = $this->yellow->toolbox->getLocationHeader($this->serverScheme, $this->serverName, "", $location);
$this->clean(301, $locationHeader);
$this->setHeader("Cache-Control", "no-cache, must-revalidate");
}
}
// Set page response header