Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #23052 [TwigBundle] Add Content-Type header for exception respons…
…e (rchoquet) This PR was merged into the 2.7 branch. Discussion ---------- [TwigBundle] Add Content-Type header for exception response | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This PR comes after I was looking to customize the way exceptions are served for a JSON API (grabbed the info at http://symfony.com/doc/current/controller/error_pages.html#overriding-the-default-exceptioncontroller). I noticed that even when changing the request format to 'json' so that the right json.twig template is served: ```php // in my override of the ExceptionController public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null) { $request->setRequestFormat('json'); return parent::showAction($request, $exception, $logger); } ``` the response Content-Type header was still 'text/html'. By now, the response Content-Type should be corresponding to the given request format. I also feel there's some room for improvement with the general "displaying error for a JSON API" chapter as it feels strange that there's no configuration option to just say "serve me anything as json", but that's another issue. Commits ------- 9e2b408 add content-type header on exception response
- Loading branch information