10000 [FrameworkBundle] non-permanent redirect to unknown location with 404 by Tobion · Pull Request #5368 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] non-permanent redirect to unknown location with 404 #5368

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 3 commits into from
Aug 29, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[FrameworkBundle] non-permanent redirect should be status code 404 ac…
…cording to spec
  • Loading branch information
Tobion committed Aug 28, 2012
commit 4c5bfab0583b13411b6c13d1da87373d46f6ff86
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class RedirectController extends ContainerAware
public function redirectAction($route, $permanent = false)
{
if (!$route) {
return new Response(null, 410);
return new Response(null, $permanent ? 410 : 404);
}

$attributes = $this->container->get('request')->attributes->get('_route_params');
Expand Down Expand Up @@ -67,7 +67,7 @@ public function redirectAction($route, $permanent = false)
public function urlRedirectAction($path, $permanent = false, $scheme = null, $httpPort = 80, $httpsPort = 443)
{
if (!$path) {
return new Response(null, 410);
return new Response(null, $permanent ? 410 : 404);
}

$statusCode = $permanent ? 301 : 302;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ public function testEmptyRoute()
$controller = new RedirectController();
$controller->setContainer($container);

$returnResponse = $controller->redirectAction('');

$returnResponse = $controller->redirectAction('', true);
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse);

$this->assertEquals(410, $returnResponse->getStatusCode());

$returnResponse = $controller->redirectAction('', false);
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse);
$this->assertEquals(404, $returnResponse->getStatusCode());
}

/**
Expand Down Expand Up @@ -102,11 +104,14 @@ public function provider()
public function testEmptyPath()
{
$controller = new RedirectController();
$returnResponse = $controller->urlRedirectAction('');

$returnResponse = $controller->urlRedirectAction('', true);
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse);

$this->assertEquals(410, $returnResponse->getStatusCode());

$returnResponse = $controller->urlRedirectAction('', false);
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse);
$this->assertEquals(404, $returnResponse->getStatusCode());
}

public function testFullURL()
Expand Down
0