From c66f74dc0d5b1286ad5f8c31138d13b2589a23ad Mon Sep 17 00:00:00 2001 From: edalzell Date: Fri, 11 Aug 2023 13:10:19 -0700 Subject: [PATCH] check buffer first --- src/Sse/ServerSentEvent.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Sse/ServerSentEvent.php b/src/Sse/ServerSentEvent.php index 7806b77..944b45d 100644 --- a/src/Sse/ServerSentEvent.php +++ b/src/Sse/ServerSentEvent.php @@ -60,7 +60,9 @@ public function __toString(): string public function __invoke() { echo $this; - ob_flush(); + if (ob_get_contents()) { + ob_flush(); + } flush(); }