Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[TwigBundle] Add Content-Type header for exception response#23052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
fabpot merged 1 commit intosymfony:2.7fromrchoquet:add-content-type-on-exception-responseJun 16, 2017
Merged
[TwigBundle] Add Content-Type header for exception response#23052
fabpot merged 1 commit intosymfony:2.7fromrchoquet:add-content-type-on-exception-responseJun 16, 2017
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Member
fabpot commentedJun 14, 2017
Don't we have the same issue on 2.7 and 2.8? If yes, then could you rebase this PR on 2.7? Thanks. |
Author
rchoquet commentedJun 15, 2017
@fabpot yep my bad, done. |
fabpot approved these changesJun 15, 2017
Member
fabpot commentedJun 16, 2017
Thank you@rchoquet. |
fabpot added a commit that referenced this pull requestJun 16, 2017
…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 athttp://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 ExceptionControllerpublic 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
This was referencedJul 3, 2017
Merged
Merged
Merged
Merged
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading.Please reload this page.
This PR comes after I was looking to customize the way exceptions are served for a JSON API (grabbed the info athttp://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:
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.