8000 [HttpFoundation] Set content-type header in RedirectResponse · symfony/symfony@954f1af · GitHub
[go: up one dir, main page]

Skip to content
8000

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+
58D8
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)
0