Skip to content

Commit

Permalink
使用SwooleFileStream时,导致isSeekable报错 (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
tw2066 authored and huangdijia committed Feb 19, 2024
1 parent 1dd5daa commit c7a16aa
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Listener/RequestHandledListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Swow\Psr7\Message\ResponsePlusInterface;
use Throwable;

use function Hyperf\Collection\collect;
use function Hyperf\Config\config;
Expand Down Expand Up @@ -123,11 +124,15 @@ protected function getResponsePayload(ResponseInterface $response): array|string
{
$stream = $response->getBody();

if ($stream->isSeekable()) {
$stream->rewind();
}
try {
if ($stream->isSeekable()) {
$stream->rewind();
}

$content = $stream->getContents();
$content = $stream->getContents();
} catch (Throwable $e) {
return 'Purged By Hyperf Telescope: ' . $e->getMessage();
}

if (is_string($content)) {
if (! $this->contentWithinLimits($content)) {
Expand Down

0 comments on commit c7a16aa

Please sign in to comment.