Skip to content
Closed
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
25 changes: 25 additions & 0 deletions src/EndOfStreamAwareHttpWorkerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Spiral\RoadRunner\Http;

/**
* @psalm-import-type HeadersList from Request
*/
interface EndOfStreamAwareHttpWorkerInterface extends HttpWorkerInterface
{
/**
* Send response to the application server.
*
* @param int $status Http status code
* @param \Generator<mixed, scalar|\Stringable, mixed, \Stringable|scalar|null>|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<array-key, array<array-key, string>> $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;
}
2 changes: 1 addition & 1 deletion src/HttpWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* @api
*/
class HttpWorker implements HttpWorkerInterface
class HttpWorker implements HttpWorkerInterface, EndOfStreamAwareHttpWorkerInterface
{
private static ?int $codec = null;

Expand Down
Loading