diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index 33e5a2a28..19d48f396 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -167,12 +167,6 @@ class Grav extends Container public function process() { - // Use output buffering to prevent headers from being sent too early. - ob_start(); - if ($this['config']->get('system.cache.gzip')) { - ob_start('ob_gzhandler'); - } - /** @var Debugger $debugger */ $debugger = $this['debugger']; @@ -185,6 +179,12 @@ class Grav extends Container $this['config']->debug(); $debugger->stopTimer('_config'); + // Use output buffering to prevent headers from being sent too early. + ob_start(); + if ($this['config']->get('system.cache.gzip')) { + ob_start('ob_gzhandler'); + } + // Initialize the timezone if ($this['config']->get('system.timezone')) { date_default_timezone_set($this['config']->get('system.timezone')); @@ -349,26 +349,29 @@ class Grav extends Container public function shutdown() { if ($this['config']->get('system.debugger.shutdown.close_connection')) { - + //stop user abort if (function_exists('ignore_user_abort')) { @ignore_user_abort(true); } + // close the session if (isset($this['session'])) { $this['session']->close(); } + // flush buffer if gzip buffer was started if ($this['config']->get('system.cache.gzip')) { ob_end_flush(); // gzhandler buffer } + // get lengh and close the connection header('Content-Length: ' . ob_get_length()); header("Connection: close\r\n"); - ob_end_flush(); // regular buffer - @ob_flush(); - flush(); + // flush the regular buffer + ob_end_flush(); + // fix for fastcgi close connection issue if (function_exists('fastcgi_finish_request')) { @fastcgi_finish_request(); }