Skip to content

Conversation

romainneutron
Copy link
Contributor

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes Build Status
License of the code: MIT

As described here fabpot/Silex#438

Add special header to customize Response StatusCode when an exception has been thrown.

This is useful as HttpKernel set response statuscode to 500 by default if the exception do not implement HttpExceptionInterface.

See test for example

… has been thrown.

This is useful as HttpKernel set response statuscode to 500 by default if the exception do not implement HttpExceptionInterface.
@@ -201,7 +201,7 @@ private function handleException(\Exception $e, $request, $type)
$response->setStatusCode($e->getStatusCode());
$response->headers->add($e->getHeaders());
} else {
$response->setStatusCode(500);
$response->setStatusCode($response->headers->get(HttpKernelInterface::HEADER_STATUSCODE, 500));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you remove the header after that ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's correct, I fixed it in the filterResponse method

@fabpot fabpot closed this in 788e5eb Jul 31, 2012
@romainneutron romainneutron deleted the ResponseHeader branch March 16, 2017 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants