-
-
Notifications
You must be signed in to change notification settings - Fork 57
Closed
Description
I was wondering why my custom class extending Symfony's BinaryFileResponse
did not call public function sendContent(): static
and I found the reason and it's concerning.
public function respond(SymfonyResponse $symfonyResponse): void
{
if ($symfonyResponse instanceof BinaryFileResponse && !$symfonyResponse->headers->has('Content-Range')) {
$content = file_get_contents($symfonyResponse->getFile()->getPathname());
if ($content === false) {
throw new \RuntimeException(sprintf("Cannot read file '%s'", $symfonyResponse->getFile()->getPathname())); // TODO: custom error
}
} else {
if ($symfonyResponse instanceof StreamedResponse || $symfonyResponse instanceof BinaryFileResponse) {
$content = '';
ob_start(function ($buffer) use (&$content) {
$content .= $buffer;
return '';
});
$symfonyResponse->sendContent();
ob_end_clean();
} else {
$content = (string) $symfonyResponse->getContent();
}
}
$headers = $this->stringifyHeaders($symfonyResponse->headers->all());
$this->httpWorker->respond($symfonyResponse->getStatusCode(), $content, $headers);
}
The bundle reads the whole file into RAM and then sends it to the RR. The main issue is that you can not send bigger files/payloads than your max_memory_limit
. I can not increase my limit to 30GB to send back huge archives, because I don't have that much RAM available.
Can something be done please?
Metadata
Metadata
Assignees
Labels
No labels