Skip to content

Commit d9a7281

Browse files
jnoordsijfabpot
authored andcommitted
[HttpFoundation] Use lowercase utf-8 as default response charset
1 parent 8261cc9 commit d9a7281

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public function prepare(Request $request): static
261261
}
262262

263263
// Fix Content-Type
264-
$charset = $this->charset ?: 'UTF-8';
264+
$charset = $this->charset ?: 'utf-8';
265265
if (!$headers->has('Content-Type')) {
266266
$headers->set('Content-Type', 'text/html; charset='.$charset);
267267
} elseif (0 === stripos($headers->get('Content-Type') ?? '', 'text/') && false === stripos($headers->get('Content-Type') ?? '', 'charset')) {

Tests/ResponseTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testSend()
6363
public function testGetCharset()
6464
{
6565
$response = new Response();
66-
$charsetOrigin = 'UTF-8';
66+
$charsetOrigin = 'utf-8';
6767
$response->setCharset($charsetOrigin);
6868
$charset = $response->getCharset();
6969
$this->assertEquals($charsetOrigin, $charset);
@@ -534,7 +534,7 @@ public function testDefaultContentType()
534534
$response = new Response('foo');
535535
$response->prepare(new Request());
536536

537-
$this->assertSame('text/html; charset=UTF-8', $response->headers->get('Content-Type'));
537+
$this->assertSame('text/html; charset=utf-8', $response->headers->get('Content-Type'));
538538
}
539539

540540
public function testContentTypeCharset()
@@ -545,7 +545,7 @@ public function testContentTypeCharset()
545545
// force fixContentType() to be called
546546
$response->prepare(new Request());
547547

548-
$this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type'));
548+
$this->assertEquals('text/css; charset=utf-8', $response->headers->get('Content-Type'));
549549
}
550550

551551
public function testContentTypeIsNull()
@@ -565,7 +565,7 @@ public function testPrepareDoesNothingIfContentTypeIsSet()
565565

566566
$response->prepare(new Request());
567567

568-
$this->assertEquals('text/plain; charset=UTF-8', $response->headers->get('content-type'));
568+
$this->assertEquals('text/plain; charset=utf-8', $response->headers->get('content-type'));
569569
}
570570

571571
public function testPrepareDoesNothingIfRequestFormatIsNotDefined()
@@ -574,7 +574,7 @@ public function testPrepareDoesNothingIfRequestFormatIsNotDefined()
574574

575575
$response->prepare(new Request());
576576

577-
$this->assertEquals('text/html; charset=UTF-8', $response->headers->get('content-type'));
577+
$this->assertEquals('text/html; charset=utf-8', $response->headers->get('content-type'));
578578
}
579579

580580
/**
@@ -588,7 +588,7 @@ public function testPrepareDoesNotSetContentTypeBasedOnRequestAcceptHeader()
588588
$request->headers->set('Accept', 'application/json');
589589
$response->prepare($request);
590590

591-
$this->assertSame('text/html; charset=UTF-8', $response->headers->get('content-type'));
591+
$this->assertSame('text/html; charset=utf-8', $response->headers->get('content-type'));
592592
}
593593

594594
public function testPrepareSetContentType()
@@ -1021,7 +1021,7 @@ public function testSettersAreChainable()
10211021

10221022
$setters = [
10231023
'setProtocolVersion' => '1.0',
1024-
'setCharset' => 'UTF-8',
1024+
'setCharset' => 'utf-8',
10251025
'setPublic' => null,
10261026
'setPrivate' => null,
10271027
'setDate' => $this->createDateTimeNow(),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy