From 8404ba7a09ca1004b9c66613b1cd104b5894c55e Mon Sep 17 00:00:00 2001 From: Gert Date: Wed, 29 Apr 2015 01:07:24 +0200 Subject: [PATCH 1/2] gzip --- system/src/Grav/Common/Grav.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index 33e5a2a28..7ba3ad4cf 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')); From 91a963f58044c819e92e56f84347fe2c4dc56b5a Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 28 Apr 2015 17:21:30 -0600 Subject: [PATCH 2/2] tweaks --- system/src/Grav/Common/Grav.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index 7ba3ad4cf..19d48f396 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -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(); }