diff --git a/src/Exception/StreamStoppedException.php b/src/Exception/StreamStoppedException.php new file mode 100644 index 0000000..48c76de --- /dev/null +++ b/src/Exception/StreamStoppedException.php @@ -0,0 +1,13 @@ +current(); if ($this->worker->getPayload(StreamStop::class) !== null) { - $body->throw(new \RuntimeException('Stream has been stopped by the client.')); + $body->throw(new StreamStoppedException()); return; } $this->worker->respond(new Payload($content, $head, false)); diff --git a/tests/Feature/StreamResponseTest.php b/tests/Feature/StreamResponseTest.php index 280b8dd..13a0450 100644 --- a/tests/Feature/StreamResponseTest.php +++ b/tests/Feature/StreamResponseTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\TestCase; use Spiral\Goridge\SocketRelay; +use Spiral\RoadRunner\Http\Exception\StreamStoppedException; use Spiral\RoadRunner\Http\HttpWorker; use Spiral\RoadRunner\Payload; use Spiral\RoadRunner\Tests\Http\Server\Command\BaseCommand; @@ -80,7 +81,7 @@ public function testStopStreamResponse(): void $this->sendCommand(new StreamStop()); try { yield ' Wo'; - } catch (\Throwable $e) { + } catch (StreamStoppedException $e) { return; } yield 'rld';