-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[HttpKernel] Additional HTTP exceptions #5312
Conversation
* upstream/master: (201 commits) Update src/Symfony/Bundle/FrameworkBundle/composer.json small optimization fixes pre for var_dump with xdebug [FrameworkBundle] Allow to set null for the handler in NativeSessionStorage added a missing phpdoc param [HttpFoundation] fixed undefined offset for assoc arrays in HeaderBag [HttpFoundation] fix #5271 (duplicated header in JsonResponse) fixed typos in the UPGRADE file fixed typo in the UPGRADE file [Form] Reintroduced the option "invalid_message_parameters" [Form] Fixed support for preferred choices in "entity" type Typo in UPGRADE-2.1 [EventDispatcher] Adding IteratorAggregate to GenericEvent fix CS into Finder 0x02 -> \MongoBinData::BYTE_ARRAY Alter upgrade notes with changes to _form_is_choice_selected twig function MongoBinData constructor now require "type" parameter Revert "merged branch guilhermeblanco/patch-6 (PR #4456)" add format to exception message Adding more specific debug bar reset CSS. ...
I would remove the InternalServerError one, as you get a 500 for any non-http exception anyway |
and please rebase your branch to get rid of the merge commit at the beginning of your PR |
@stof Can you provide some pointers on how to get rid of the merge commit through a rebase? I generally avoid rebase, so doing this is fairly new to me. I realize that what created the commit was a non-fast-forward merge, so I just need to understand how to get it to apply merges cleanly without creating merge commits like that. Thanks! |
If you want to rebase your branch on 2.1:
|
@ramsey http://symfony.com/doc/current/contributing/code/patches.html#rework-your-patch for the documentation about the way to do it |
@ramsey ping |
I'm going to finish this PR, but #5862 should be merged first. |
Sorry I've been sitting on this for so long. I haven't had time to figure out how to get rid of the merge commit, as @stof requested. That's the only outstanding issue here, as far as I know. |
I can see another issue. For some HTTP codes, you can/should/must add some headers or some content (like for the 406 status code). Don't worry about the merge commit or the rebasing, I will take care of that myself when merging the PR. |
I don't know what header is required for the 406 status code. RFC 2616 doesn't specify one. It does say "the response should include an entity containing a list of available entity characteristics and locations." In other exceptions, such as UnauthorizedHttpException, TooManyRequestsHttpException, and ServiceUnavailableException, I did provide the required headers. On Monday, October 29, 2012 at 10:48 AM, Fabien Potencier wrote:
|
merged, thanks. |
Thanks! |
I wanted to continue using exceptions for many other types of HTTP 4xx and 5xx status codes, particularly because I like the notion that I can trap the exception based on the type, rather than inspecting HttpException to see what status code it contains. I've decided to contribute these back to the Symfony HttpKernel component, in case others find them useful.
This pull request provides the following new HttpKernel Exceptions:
400 Bad Request
409 Conflict
410 Gone
500 Internal Server Error
411 Length Required
406 Not Acceptable
412 Precondition Failed
428 Precondition Required
†503 Service Unavailable
429 Too Many Requests
†401 Unauthorized
415 Unsupported Media Type
All the tests have been placed in the FlattenExceptionTest, since that's where the previous status code and method tests for HttpException exceptions are located, but I can move them to a more logical location, if needed.
† These codes have been included from RFC 6585, Additional HTTP Status Codes.