diff --git a/src/Http/Concerns/ResponseTrait.php b/src/Http/Concerns/ResponseTrait.php index 34795d1..9204231 100644 --- a/src/Http/Concerns/ResponseTrait.php +++ b/src/Http/Concerns/ResponseTrait.php @@ -176,12 +176,20 @@ public function download(SplFileInfo|string $file, ?string $name = null, array $ * Créez une nouvelle instance de réponse diffusée en continu sous forme de téléchargement de fichier. */ public function streamDownload(callable|StreamInterface|string $stream, string $name, array $headers = []): static + { + return $this->stream($stream, $name, $headers)->withDownload($name); + } + + /** + * Créez une nouvelle instance de réponse diffusée en continu. + */ + public function stream(callable|StreamInterface|string $stream, string $name, array $headers = []): static { if (! ($stream instanceof StreamInterface)) { - $stream = to_stream($stream); + $stream = Utils::streamFor($stream); } - return $this->withHeaders($headers)->withBody($stream)->withType(pathinfo($name, PATHINFO_EXTENSION))->withDownload($name); + return $this->withHeaders($headers)->withBody($stream)->withType(pathinfo($name, PATHINFO_EXTENSION)); } /**