mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 20:44:28 +09:00
Fix incorrect server push detection when using CloudFlare
This commit is contained in:
parent
9e78c66f7c
commit
4b27a503b5
1 changed files with 27 additions and 2 deletions
|
|
@ -442,7 +442,7 @@ class FrontEndFileHandler extends Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable HTTP/2 server push for CSS resources.
|
// Enable HTTP/2 server push for CSS resources.
|
||||||
if ($finalize && config('view.server_push') && strncmp($_SERVER['SERVER_PROTOCOL'], 'HTTP/2', 6) === 0)
|
if ($finalize && $this->_isServerPushEnabled())
|
||||||
{
|
{
|
||||||
foreach ($result as $resource)
|
foreach ($result as $resource)
|
||||||
{
|
{
|
||||||
|
|
@ -546,7 +546,7 @@ class FrontEndFileHandler extends Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable HTTP/2 server push for JS resources.
|
// Enable HTTP/2 server push for JS resources.
|
||||||
if ($type === 'head' && $finalize && config('view.server_push') && strncmp($_SERVER['SERVER_PROTOCOL'], 'HTTP/2', 6) === 0)
|
if ($type === 'head' && $finalize && $this->_isServerPushEnabled())
|
||||||
{
|
{
|
||||||
foreach ($result as $resource)
|
foreach ($result as $resource)
|
||||||
{
|
{
|
||||||
|
|
@ -667,6 +667,31 @@ class FrontEndFileHandler extends Handler
|
||||||
$cssSortList = array('common' => -100000, 'layouts' => -90000, 'modules' => -80000, 'widgets' => -70000, 'addons' => -60000);
|
$cssSortList = array('common' => -100000, 'layouts' => -90000, 'modules' => -80000, 'widgets' => -70000, 'addons' => -60000);
|
||||||
$file->index = $cssSortList[$tmp[0]];
|
$file->index = $cssSortList[$tmp[0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if server push is enabled.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function _isServerPushEnabled()
|
||||||
|
{
|
||||||
|
if (!config('view.server_push'))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
elseif (strncmp($_SERVER['SERVER_PROTOCOL'], 'HTTP/2', 6) === 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
elseif (isset($_SERVER['HTTP_CF_VISITOR']) && \RX_SSL)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* End of file FrontEndFileHandler.class.php */
|
/* End of file FrontEndFileHandler.class.php */
|
||||||
/* Location: ./classes/frontendfile/FrontEndFileHandler.class.php */
|
/* Location: ./classes/frontendfile/FrontEndFileHandler.class.php */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue