diff --git a/Protocols/Http/ServerSentEvents.php b/Protocols/Http/ServerSentEvents.php index 7aeafc70d..a6e9e0d75 100644 --- a/Protocols/Http/ServerSentEvents.php +++ b/Protocols/Http/ServerSentEvents.php @@ -50,15 +50,15 @@ public function __toString() if (isset($data['event'])) { $buffer .= "event: {$data['event']}\n"; } - if (isset($data['data'])) { - $buffer .= 'data: ' . \str_replace("\n", "\ndata: ", $data['data']) . "\n\n"; - } if (isset($data['id'])) { $buffer .= "id: {$data['id']}\n"; } if (isset($data['retry'])) { $buffer .= "retry: {$data['retry']}\n"; } - return $buffer; + if (isset($data['data'])) { + $buffer .= 'data: ' . str_replace("\n", "\ndata: ", $data['data']) . "\n"; + } + return $buffer . "\n"; } } \ No newline at end of file