Skip to content

feat: SSEResponse class for streaming Server-Side Events#9931

Open
michalsn wants to merge 3 commits intocodeigniter4:4.8from
michalsn:feat/sse-response
Open

feat: SSEResponse class for streaming Server-Side Events#9931
michalsn wants to merge 3 commits intocodeigniter4:4.8from
michalsn:feat/sse-response

Conversation

@michalsn
Copy link
Member

@michalsn michalsn commented Feb 6, 2026

Description
This PR introduces SSEResponse, a new response class for streaming Server-Sent Events over HTTP. The class provides event(), comment(), and retry() methods for sending SSE fields to the client. Array data passed to event() is automatically JSON-encoded. The response also handles output buffering, session closing, and appropriate header management.

SSEResponse implements the NonBufferedResponseInterface, which is shared with DownloadResponse. Guard checks in CodeIgniter, PageCache, and the Toolbar that previously referenced DownloadResponse directly now rely on this interface instead. This ensures that both download and SSE responses are correctly excluded from page caching, toolbar injection, and body rendering.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@michalsn michalsn added new feature PRs for new features 4.8 PRs that target the `4.8` branch. labels Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.8 PRs that target the `4.8` branch. new feature PRs for new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant