[HttpKernel] fixed HTTP exception headers in ExceptionHandler

This commit is contained in:
Fabien Potencier 2012-07-13 12:14:13 +02:00
parent 3f05e7047f
commit 498759a2e8
2 changed files with 11 additions and 1 deletions

View File

@ -100,7 +100,7 @@ class ExceptionHandler
}
}
return new Response($this->decorate($content, $title), $exception->getStatusCode());
return new Response($this->decorate($content, $title), $exception->getStatusCode(), $exception->getHeaders());
}
private function getContent($exception)

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\HttpKernel\Tests\Debug;
use Symfony\Component\HttpKernel\Debug\ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
{
@ -51,6 +52,15 @@ class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
$this->assertContains('<title>Sorry, the page you are looking for could not be found.</title>', $response->getContent());
}
public function testHeaders()
{
$handler = new ExceptionHandler(false);
$response = $handler->createResponse(new MethodNotAllowedHttpException(array('POST')));
$this->assertEquals('405', $response->getStatusCode());
$this->assertEquals('POST', $response->headers->get('Allow'));
}
public function testNestedExceptions()
{
$handler = new ExceptionHandler(true);