Repository navigation
[Server] Stream handshake-era responses on servers that write the body themselves - #706
Merged
chr-hertel merged 3 commits intoNov 9, 2026
Conversation
webagil-kevin
requested review from
CodeWithKyrian,
Nyholm,
chr-hertel and
soyuka
as code owners
November 9, 2026 02:47
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the handshake-era streaming changes.
No open issues 🎉
What changed in this PR
Extends the streaming support from #691 to handshake-era responses, allowing HTTP servers that write response bodies themselves to deliver notifications and wait for client replies without blocking their event loop.
Changes:
- Exposes handshake-era SSE frames through
CallbackStream::chunks(), yielding idle turns while awaiting client replies. - Updates Revolt and ReactPHP examples to stream these responses and report progress, removing their
501fallback. - Adds event-loop and interoperability coverage, updates documentation, and records the protected-method removals as a breaking change.
| File | Description |
|---|---|
tests/Unit/Server/Fiber/RealEventLoopTest.php |
Covers notification streaming, client replies, and handler cleanup when chunks are dropped. |
tests/Interop/Server/Http/HttpRevoltTest.php |
Checks handshake-era progress streaming through Revolt. |
tests/Interop/Server/Http/HttpReactPhpTest.php |
Checks handshake-era progress streaming through ReactPHP. |
src/Server/Transport/StreamableHttpTransport.php |
Produces handshake-era frames through a generator with idle yields. |
examples/server/revolt/SlowTools.php |
Reports progress halfway through the wait tool. |
examples/server/revolt/server.php |
Removes the unsupported-streaming fallback. |
examples/server/README.md |
Documents streaming support for both protocol eras. |
examples/server/reactphp/SlowTools.php |
Reports progress halfway through the wait tool. |
examples/server/reactphp/server.php |
Removes the unsupported-streaming fallback. |
docs/run/server-builder.md |
Explains chunk consumption and event-loop pacing for both eras. |
CHANGELOG.md |
Records handshake-era streaming and protected-method removal. |
Review effort: Balanced
chr-hertel
approved these changes
Nov 9, 2026
chr-hertel
left a comment
Member
There was a problem hiding this comment.
Thanks again @webagil-kevin!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #691, for the handshake era. A server that sends the PSR-7 body itself, like
amphp/http-serverorreact/http, still answered501when a handshake-era response needed streaming. And while a handler waited for an answer from the client, the transport blocked the loop, so the answer could not arrive and the request failed when the wait timed out.CallbackStream::chunks()now also hands out handshake-era streamed responses. While a handler waits for the client, the generator yields idle turns: the server waits on its loop, and another request can bring the answer.StreamableHttpTransportno longer has the protectedflushOutgoingMessages()andhandleFiberTermination(), as the frames now come from the generator: a[BC Break]for subclasses.501fallback, and theirwaittool reports progress halfway, which the interop tests read as a handshake-era stream.