[HttpKernel] fixed HTTP exception headers in ExceptionHandler
This commit is contained in:
parent
3f05e7047f
commit
498759a2e8
@ -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)
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user