Skip to content

Commit af9fbb3

Browse files
[HttpFoundation] Fix BinaryFileResponse
1 parent d9afb27 commit af9fbb3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

BinaryFileResponse.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,19 @@ public function sendContent()
342342
$length = $this->maxlen;
343343
while ($length && !feof($file)) {
344344
$read = $length > $this->chunkSize || 0 > $length ? $this->chunkSize : $length;
345-
$read = stream_copy_to_stream($file, $out, $read);
346345

347-
if (false === $read || connection_aborted()) {
346+
if (false === $data = fread($file, $read)) {
348347
break;
349348
}
350-
if (0 < $length) {
351-
$length -= $read;
349+
while ('' !== $data) {
350+
$read = fwrite($out, $data);
351+
if (false === $read || connection_aborted()) {
352+
break;
353+
}
354+
if (0 < $length) {
355+
$length -= $read;
356+
}
357+
$data = substr($data, $read);
352358
}
353359
}
354360

0 commit comments

Comments
 (0)