Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ $server->addHttpHandler(function ($request, $response) {
event: 'tick', // addEventListener('tick', …) on the client
id: (string) $i, // echoed back as Last-Event-ID on reconnect
);
if (!$response->sendable()) break; // peer gone — stop early
}

$response->end();
Expand Down
10 changes: 9 additions & 1 deletion stubs/HttpResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ public function getProtocolVersion(): string {}
// === Body methods ===

/**
* Write data to response body buffer
* Append data to the buffered response body.
*
* Nothing reaches the client here: the whole body goes out on end(),
* with Content-Length computed from it. Use send() to stream instead —
* that is the call which commits headers and applies backpressure.
*
* @param string $data Data to write
* @return static
Expand Down Expand Up @@ -220,6 +224,10 @@ public function writeMessage(string $message): static {}
* send() is always safe to call regardless; sendable() just lets a
* handler do other work instead of blocking on a slow peer.
*
* False does not report a departed client: a peer that is gone surfaces
* as HttpException 499 out of send(). A loop that breaks on false stops a
* stream that is merely slow.
*
* @return bool
*/
public function sendable(): bool {}
Expand Down
Loading