diff --git a/src/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php b/src/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php index 9dcefc7a12..848f3ccf5b 100644 --- a/src/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php @@ -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) diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/ExceptionHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/ExceptionHandlerTest.php index 8c61f5a57d..c13e559362 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/ExceptionHandlerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/ExceptionHandlerTest.php @@ -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('Sorry, the page you are looking for could not be found.', $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);