Fixed missing Content-Type headers when loading internal static assets (e.g. /__pickles/css/reset.css)

This commit is contained in:
Josh Sherman 2011-04-09 16:34:49 -04:00
parent a2f2e98195
commit d9436919bd

View file

@ -60,14 +60,18 @@ class Controller extends Object
}
// Catches requests to PICKLES core files and passes them through
if (preg_match('/^__pickles\/(css|js)\/.+$/', $_REQUEST['request']))
if (preg_match('/^__pickles\/(css|js)\/.+$/', $_REQUEST['request'], $matches))
{
// Checks that the file exists
$file = str_replace('__pickles', PICKLES_PATH, $_REQUEST['request']);
$file = str_replace('__pickles/', PICKLES_PATH, $_REQUEST['request']);
if (file_exists($file))
{
// Sets the pass thru flag and dumps the data
$this->passthru = true;
// This is somewhat hacky, but mime_content_type() is deprecated and finfo_file() is only 5.3+
header('Content-Type: text/' . ($matches[1] == 'js' ? 'javascript' : $matches[1]));
exit(file_get_contents($file));
}
}