Skip to content

Commit 6f9c2ba

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: fix unix root dir issue sync validator translation files with master [HttpFoundation] fix not sending Content-Type header for 204 responses [ErrorHandler] silence warning when zend.assertions=-1 fix anchor [Console] Handle zero row count in appendRow() for Table fix links to releases page (formerly known as "roadmap") [Console] Don't load same-namespace alternatives on exact match found
2 parents 690d902 + 7e41b4f commit 6f9c2ba

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

Response.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,12 @@ public function prepare(Request $request)
258258
$this->setContent(null);
259259
$headers->remove('Content-Type');
260260
$headers->remove('Content-Length');
261+
// prevent PHP from sending the Content-Type header based on default_mimetype
262+
ini_set('default_mimetype', '');
261263
} else {
262264
// Content-type based on the Request
263265
if (!$headers->has('Content-Type')) {
264-
$format = $request->getPreferredFormat();
266+
$format = $request->getPreferredFormat(null);
265267
if (null !== $format && $mimeType = $request->getMimeType($format)) {
266268
$headers->set('Content-Type', $mimeType);
267269
}

Tests/ResponseTest.php

+2-10
Original file line numberDiff line numberDiff line change
@@ -461,18 +461,10 @@ public function testSetVary()
461461

462462
public function testDefaultContentType()
463463
{
464-
$headerMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\ResponseHeaderBag')->setMethods(['set'])->getMock();
465-
$headerMock->expects($this->at(0))
466-
->method('set')
467-
->with('Content-Type', 'text/html');
468-
$headerMock->expects($this->at(1))
469-
->method('set')
470-
->with('Content-Type', 'text/html; charset=UTF-8');
471-
472464
$response = new Response('foo');
473-
$response->headers = $headerMock;
474-
475465
$response->prepare(new Request());
466+
467+
$this->assertSame('text/html; charset=UTF-8', $response->headers->get('Content-Type'));
476468
}
477469

478470
public function testContentTypeCharset()

0 commit comments

Comments
 (0)