From 24438c93c5330550c93c34ce604195f47fd0aac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Danyi?= Date: Mon, 6 Aug 2018 18:03:21 +0200 Subject: [PATCH] * avatar content-type fixed --- src/App/Action/AvatarAction.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/App/Action/AvatarAction.php b/src/App/Action/AvatarAction.php index 7e0b65a..184d26d 100644 --- a/src/App/Action/AvatarAction.php +++ b/src/App/Action/AvatarAction.php @@ -3,6 +3,7 @@ namespace App\Action; use App\Service\AvatarService; +use finfo; use Interop\Http\ServerMiddleware\DelegateInterface; use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface; use Psr\Http\Message\ServerRequestInterface; @@ -31,8 +32,10 @@ class AvatarAction implements ServerMiddlewareInterface } catch (\UnexpectedValueException $e) { return new TextResponse("Avatar not found", 404); } + $finfo = new finfo(FILEINFO_MIME_TYPE); + $contentType = $finfo->buffer($avatarImageData); return (new TextResponse($avatarImageData, 200, [ - 'content-type' => 'image/png', + 'content-type' => $contentType, ]))->withHeader('Expires', '0') ->withHeader('Cache-Control', 'must-revalidate'); }