Skip to content

Commit

Permalink
[HttpFoundation] fix not sending Content-Type header for 204 responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobion committed Feb 13, 2020
1 parent e87b599 commit e868336
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Symfony/Component/HttpFoundation/Response.php
Expand Up @@ -267,10 +267,12 @@ public function prepare(Request $request)
$this->setContent(null);
$headers->remove('Content-Type');
$headers->remove('Content-Length');
// prevent PHP from sending the Content-Type header based on default_mimetype
ini_set('default_mimetype', '');
} else {
// Content-type based on the Request
if (!$headers->has('Content-Type')) {
$format = $request->getPreferredFormat();
$format = $request->getPreferredFormat(null);
if (null !== $format && $mimeType = $request->getMimeType($format)) {
$headers->set('Content-Type', $mimeType);
}
Expand Down

0 comments on commit e868336

Please sign in to comment.