-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Kernel] deprecate X-Status-Code #12343
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
I will start with this issue on Hackday |
Hi @Tobion, this header is been used not only on exceptions also used in symfony/src/Symfony/Component/Security/Http/EntryPoint/FormAuthenticationEntryPoint.php Line 57 in d94d837 8000
|
@desarolla2 have you got any result on this ? |
Nop, sorry. |
Updates ? |
6 tasks
@devsdmf I've created a PR with this work |
fabpot
added a commit
that referenced
this issue
Mar 1, 2017
…ative (jameshalsall) This PR was merged into the 3.3-dev branch. Discussion ---------- [HttpKernel] Deprecate X-Status-Code for better alternative | Q | A | | --- | --- | | Branch? | master | | Bug fix? | no | | New feature? | yes | | BC breaks? | no | | Deprecations? | yes | | Tests pass? | yes | | Fixed tickets | #12343 | | License | MIT | | Doc PR | symfony/symfony-docs#6948 | This marks the X-Status-Code header method of setting a custom response status code in exception listeners for a better alternative. There is now a new method on the `GetResponseForExceptionEvent` that allows successful status codes in the response sent to the client. The old method of setting the X-Status-Code header will now throw a deprecation warning. Instead, in your exception listener you simply call `GetResponseForExceptionEvent::allowCustomResponseCode()` which will tell the Kernel not to override the status code of the event's response object. Currenty the `X-Status-Code` header will still be removed, so as not to change the existing behaviour, but this is something we can remove in 4.0. TODO: - [x] Replace usage of X-Status-Code in `FormAuthenticationEntryPoint` - [x] Open Silex issue - [x] Rename method on the response - [x] Ensure correct response code is set in `AuthenticationEntryPointInterface` implementations - [x] Ensure the exception listeners are marking `GetResponseForExceptionEvent` as allowing a custom response code - [x] In the Security component we should only use the new method of setting a custom response code if it is available, and fall back to the `X-Status-Code` method Commits ------- cc0ef28 [HttpKernel] Deprecate X-Status-Code for better alternative
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The handling of the
X-Status-Code
header in der kernel introduced in 788e5eb is a hack and just introduced as a workaround. First of all it's magic (why this header?) and second of all it disallows to actually return such a header because it's removed automatically. So you cannot send a response with this header even if you need to.It should be deprecated and replaced by a better solution. Alternatives:
GetResponseForExceptionEvent::allowSuccessfulResponse
setter/getter to the event. When true (default false), it will use the Response status code even if it's a 2xx for an exception.The text was updated successfully, but these errors were encountered: