Skip to content

Commit 954f1af

Browse files
smnandrechalasr
authored andcommitted
[HttpFoundation] Set content-type header in RedirectResponse
1 parent 2377fc7 commit 954f1af

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Symfony/Component/HttpFoundation/RedirectResponse.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public function setTargetUrl(string $url)
103103
</html>', htmlspecialchars($url, \ENT_QUOTES, 'UTF-8')));
104104

105105
$this->headers->set('Location', $url);
106+
$this->headers->set('Content-Type', 'text/html; charset=utf-8');
106107

107108
return $this;
108109
}

src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public function testGenerateLocationHeader()
4444
$this->assertEquals('foo.bar', $response->headers->get('Location'));
4545
}
4646

47+
public function testGenerateContentTypeHeader()
48+
{
49+
$response = new RedirectResponse('foo.bar');
50+
51+
$this->assertSame('text/html; charset=utf-8', $response->headers->get('Content-Type'));
52+
}
53+
4754
public function testGetTargetUrl()
4855
{
4956
$response = new RedirectResponse('foo.bar');

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