8000 [HttpFoundation] Set content-type header in RedirectResponse by smnandre · Pull Request #54506 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] Set content-type header in RedirectResponse #54506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
< 8000 div data-show-on-forbidden-error hidden>

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[HttpFoundation] Set content-type header in RedirectResponse
  • Loading branch information
smnandre authored and chalasr committed Apr 6, 2024
commit 954f1af385536edae9a87b83da761b1de089e673
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpFoundation/RedirectResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public function setTargetUrl(string $url)
</html>', htmlspecialchars($url, \ENT_QUOTES, 'UTF-8')));

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

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public function testGenerateLocationHeader()
$this->assertEquals('foo.bar', $response->headers->get('Location'));
}

public function testGenerateContentTypeHeader()
{
$response = new RedirectResponse('foo.bar');

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

public function testGetTargetUrl()
{
$response = new RedirectResponse('foo.bar');
Expand Down
0