diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 6766f2c77099e..455b026dffb05 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -261,7 +261,7 @@ public function prepare(Request $request): static } // Fix Content-Type - $charset = $this->charset ?: 'UTF-8'; + $charset = $this->charset ?: 'utf-8'; if (!$headers->has('Content-Type')) { $headers->set('Content-Type', 'text/html; charset='.$charset); } elseif (0 === stripos($headers->get('Content-Type') ?? '', 'text/') && false === stripos($headers->get('Content-Type') ?? '', 'charset')) { diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 2c761a4f8ad17..26ce83df1c48d 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -63,7 +63,7 @@ public function testSend() public function testGetCharset() { $response = new Response(); - $charsetOrigin = 'UTF-8'; + $charsetOrigin = 'utf-8'; $response->setCharset($charsetOrigin); $charset = $response->getCharset(); $this->assertEquals($charsetOrigin, $charset); @@ -534,7 +534,7 @@ public function testDefaultContentType() $response = new Response('foo'); $response->prepare(new Request()); - $this->assertSame('text/html; charset=UTF-8', $response->headers->get('Content-Type')); + $this->assertSame('text/html; charset=utf-8', $response->headers->get('Content-Type')); } public function testContentTypeCharset() @@ -545,7 +545,7 @@ public function testContentTypeCharset() // force fixContentType() to be called $response->prepare(new Request()); - $this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type')); + $this->assertEquals('text/css; charset=utf-8', $response->headers->get('Content-Type')); } public function testContentTypeIsNull() @@ -565,7 +565,7 @@ public function testPrepareDoesNothingIfContentTypeIsSet() $response->prepare(new Request()); - $this->assertEquals('text/plain; charset=UTF-8', $response->headers->get('content-type')); + $this->assertEquals('text/plain; charset=utf-8', $response->headers->get('content-type')); } public function testPrepareDoesNothingIfRequestFormatIsNotDefined() @@ -574,7 +574,7 @@ public function testPrepareDoesNothingIfRequestFormatIsNotDefined() $response->prepare(new Request()); - $this->assertEquals('text/html; charset=UTF-8', $response->headers->get('content-type')); + $this->assertEquals('text/html; charset=utf-8', $response->headers->get('content-type')); } /** @@ -588,7 +588,7 @@ public function testPrepareDoesNotSetContentTypeBasedOnRequestAcceptHeader() $request->headers->set('Accept', 'application/json'); $response->prepare($request); - $this->assertSame('text/html; charset=UTF-8', $response->headers->get('content-type')); + $this->assertSame('text/html; charset=utf-8', $response->headers->get('content-type')); } public function testPrepareSetContentType() @@ -1021,7 +1021,7 @@ public function testSettersAreChainable() $setters = [ 'setProtocolVersion' => '1.0', - 'setCharset' => 'UTF-8', + 'setCharset' => 'utf-8', 'setPublic' => null, 'setPrivate' => null, 'setDate' => $this->createDateTimeNow(),