diff --git a/code/dispatcher/response/transport/http.php b/code/dispatcher/response/transport/http.php index 0141b8fece..5caf03e70c 100644 --- a/code/dispatcher/response/transport/http.php +++ b/code/dispatcher/response/transport/http.php @@ -69,11 +69,16 @@ public function sendHeaders(DispatcherResponseInterface $response) public function sendContent(DispatcherResponseInterface $response) { //Make sure the output buffers are cleared - $level = ob_get_level(); - while($level > 0) { + foreach(ob_get_status(true) as $status) + { + //Do not try to clear the 'zlib output compression' + //See: https://github.com/timble/kodekit/issues/70 + if($status['name'] == 'zlib output compression') { + break; + } + ob_end_clean(); - $level--; - }; + } echo $response->getStream()->toString(); return $this; diff --git a/code/dispatcher/response/transport/stream.php b/code/dispatcher/response/transport/stream.php index 1170d7773e..38ca472c90 100644 --- a/code/dispatcher/response/transport/stream.php +++ b/code/dispatcher/response/transport/stream.php @@ -194,10 +194,15 @@ public function sendContent(DispatcherResponseInterface $response) } //Make sure the output buffers are cleared - $level = ob_get_level(); - while($level > 0) { + foreach(ob_get_status(true) as $status) + { + //Do not try to clear the 'zlib output compression' + //See: https://github.com/timble/kodekit/issues/70 + if($status['name'] == 'zlib output compression') { + break; + } + ob_end_clean(); - $level--; } $stream = $response->getStream(); diff --git a/code/exception/handler/abstract.php b/code/exception/handler/abstract.php index 2ebe10404a..76f38d4a9d 100644 --- a/code/exception/handler/abstract.php +++ b/code/exception/handler/abstract.php @@ -318,10 +318,15 @@ public function handleException(\Exception $exception) ); //Make sure the output buffers are cleared - $level = ob_get_level(); - while($level > 0) { + foreach(ob_get_status(true) as $status) + { + //Do not try to clear the 'zlib output compression' + //See: https://github.com/timble/kodekit/issues/70 + if($status['name'] == 'zlib output compression') { + break; + } + ob_end_clean(); - $level--; } if (ini_get('display_errors')) {