From c3262dd74ba95f91948e61baf4c3893dd862d5de Mon Sep 17 00:00:00 2001 From: rekcuFniarB Date: Sun, 12 Jan 2020 02:35:12 +0300 Subject: [PATCH] Fixing issue #399 headers not sent if buffer length exceedes value defined in ini.output_buffering. It's better to flush buffer after sending response. https://github.com/klein/klein.php/issues/399 --- src/Klein/Klein.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Klein/Klein.php b/src/Klein/Klein.php index 587379fd..feadaf9c 100644 --- a/src/Klein/Klein.php +++ b/src/Klein/Klein.php @@ -690,10 +690,6 @@ public function dispatch( while (ob_get_level() >= $this->output_buffer_level) { ob_end_clean(); } - } elseif (self::DISPATCH_NO_CAPTURE === $capture) { - while (ob_get_level() >= $this->output_buffer_level) { - ob_end_flush(); - } } } catch (LockedResponseException $e) { // Do nothing, since this is an automated behavior @@ -705,6 +701,12 @@ public function dispatch( if ($send_response && !$this->response->isSent()) { $this->response->send(); } + + if (self::DISPATCH_NO_CAPTURE === $capture) { + while (ob_get_level() >= $this->output_buffer_level) { + ob_end_flush(); + } + } } /**