mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Optimized clean response handling
This commit is contained in:
parent
2cc4f4d382
commit
f1da3ef5e8
2
app.php
2
app.php
@ -101,4 +101,6 @@ $errorMiddleware->setDefaultErrorHandler(
|
||||
);
|
||||
|
||||
$app->add(new CorsMiddleware($app->getResponseFactory()));
|
||||
|
||||
ob_clean(); // No response output before here
|
||||
$app->run();
|
||||
|
@ -49,7 +49,6 @@ class CalendarApiController extends BaseApiController
|
||||
$vCalendar->addEvent($vEvent);
|
||||
}
|
||||
|
||||
ob_clean(); // Make sure to ONLY return the file
|
||||
$response->write((new CalendarFactory())->createCalendar($vCalendar));
|
||||
$response = $response->withHeader('Content-Type', 'text/calendar; charset=utf-8');
|
||||
return $response->withHeader('Content-Disposition', 'attachment; filename="grocy.ics"');
|
||||
|
@ -49,7 +49,6 @@ class FilesApiController extends BaseApiController
|
||||
|
||||
if (file_exists($filePath))
|
||||
{
|
||||
ob_clean(); // Make sure to ONLY return the file
|
||||
$response->write(file_get_contents($filePath));
|
||||
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
|
||||
$response = $response->withHeader('Content-Type', mime_content_type($filePath));
|
||||
@ -81,7 +80,6 @@ class FilesApiController extends BaseApiController
|
||||
|
||||
if (file_exists($filePath))
|
||||
{
|
||||
ob_clean(); // Make sure to ONLY return the file
|
||||
$response->write(file_get_contents($filePath));
|
||||
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
|
||||
$response = $response->withHeader('Content-Type', mime_content_type($filePath));
|
||||
|
Loading…
x
Reference in New Issue
Block a user