27 lines
509 B
PHP
27 lines
509 B
PHP
<?php
|
|
header("Content-Type: text/event-stream");
|
|
header("Cache-Control: no-cache");
|
|
header("X-Accel-Buffering: no");
|
|
header("Connection: keep-alive");
|
|
if ($_SERVER["REQUEST_METHOD"] === "OPTIONS") { http_response_code(200); exit; }
|
|
ob_implicit_flush(true);
|
|
while (ob_get_level()) @ob_end_flush();
|
|
|
|
echo "event: start
|
|
data: " . json_encode(["hello"=>"ambre"]) . "
|
|
|
|
";
|
|
@flush();
|
|
sleep(1);
|
|
echo "event: step
|
|
data: " . json_encode(["step"=>1]) . "
|
|
|
|
";
|
|
@flush();
|
|
sleep(1);
|
|
echo "event: done
|
|
data: {}
|
|
|
|
";
|
|
@flush();
|