/** * Convert SSE event source into an HTTP response. */ public function __invoke(HttpRequest $request, $source) { if ($source instanceof EventSource) { $response = new HttpResponse(Http::OK, ['Content-Type' => 'text/event-stream', 'Cache-Control' => 'no-cache']); return $response->withBody(new EventBody($source)); } }