Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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-response
Jun 16, 2017
Merged

[TwigBundle] Add Content-Type header for exception response#23052

fabpot merged 1 commit intosymfony:2.7fromrchoquet:add-content-type-on-exception-response
Jun 16, 2017

Conversation

@rchoquet
Copy link

@rchoquetrchoquet commentedJun 3, 2017
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
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:

// in my override of the ExceptionControllerpublicfunctionshowAction(Request$request,FlattenException$exception,DebugLoggerInterface$logger =null){$request->setRequestFormat('json');returnparent::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.

Netmisa reacted with thumbs up emoji
@rchoquetrchoquet changed the base branch frommaster to3.2June 3, 2017 18:41
@nicolas-grekasnicolas-grekas added this to the3.2 milestoneJun 4, 2017
@fabpot
Copy link
Member

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.

@rchoquetrchoquet changed the base branch from3.2 to2.7June 15, 2017 09:47
@rchoquet
Copy link
Author

@fabpot yep my bad, done.

@fabpot
Copy link
Member

Thank you@rchoquet.

@fabpotfabpot merged commit9e2b408 intosymfony:2.7Jun 16, 2017
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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.2

Development

Successfully merging this pull request may close these issues.

4 participants

@rchoquet@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp