Closed
Description
Q | A |
---|---|
Bug report? | no |
Feature request? | yes |
BC Break report? | no |
Symfony version | 3.3 |
While writing the New in Symfony 3.3: Deprecated X-Status-Code blog post, I wondered why we need allowCustomResponseCode()
. Let me show some code:
This is what we have in Symfony 3.2
$exception = $event->getException();
$response = new Response('...', 500, ['X-Status-Code' => 404]);
$event->setResponse($response);
This is the solution proposed by Symfony 3.3
$exception = $event->getException();
$response = new Response('...', 404);
$event->allowCustomResponseCode();
$event->setResponse($response);
This is what I want
$exception = $event->getException();
$response = new Response('...', 404);
$event->setResponse($response);
Removing X-Status-Code
is great and help us reduce the "cognitive load" required to use Symfony ... but all those gains are lost when introducing allowCustomResponseCode()
.