From 5c065fbdd69bb9453f01c3a3e7f5a6bee7da2ed1 Mon Sep 17 00:00:00 2001 From: Kenny1911 Date: Wed, 18 Feb 2026 00:08:49 +0400 Subject: [PATCH] EndOfStreamAwareHttpWorkerInterface --- src/EndOfStreamAwareHttpWorkerInterface.php | 25 +++++++++++++++++++++ src/HttpWorker.php | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/EndOfStreamAwareHttpWorkerInterface.php diff --git a/src/EndOfStreamAwareHttpWorkerInterface.php b/src/EndOfStreamAwareHttpWorkerInterface.php new file mode 100644 index 0000000..7ae8cea --- /dev/null +++ b/src/EndOfStreamAwareHttpWorkerInterface.php @@ -0,0 +1,25 @@ +|string $body Body of response. + * If the body is a generator, then each yielded value will be sent as a separated stream chunk. + * Returned value will be sent as a last stream package. + * Note: Stream response is supported by RoadRunner since version 2023.3 + * @param HeadersList|array> $headers $headers An associative array of the + * message's headers. Each key MUST be a header name, and each value MUST be an array of strings for + * that header. + */ + public function respond(int $status, string|\Generator $body = '', array $headers = [], bool $endOfStream = true): void; +} diff --git a/src/HttpWorker.php b/src/HttpWorker.php index dd9528f..a4042bc 100644 --- a/src/HttpWorker.php +++ b/src/HttpWorker.php @@ -38,7 +38,7 @@ * * @api */ -class HttpWorker implements HttpWorkerInterface +class HttpWorker implements HttpWorkerInterface, EndOfStreamAwareHttpWorkerInterface { private static ?int $codec = null;