From fde2b0c3c40a037c118dad814c9226310637b5e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20R=C3=B6gels?= Date: Tue, 16 Mar 2021 17:59:55 +0100 Subject: [PATCH] Responses with HTTP status 204 or 304 must not have set the Content-Type header. --- View/ViewHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/View/ViewHandler.php b/View/ViewHandler.php index 6e638fbb2..6d63ab6ce 100644 --- a/View/ViewHandler.php +++ b/View/ViewHandler.php @@ -189,7 +189,7 @@ public function createResponse(View $view, Request $request, string $format): Re $response = $this->initResponse($view, $format); - if (!$response->headers->has('Content-Type')) { + if (!$response->headers->has('Content-Type') && !in_array($response->getStatusCode(), [204, 304])) { $mimeType = $request->attributes->get('media_type'); if (null === $mimeType) { $mimeType = $request->getMimeType($format);