Skip to content

Commit

Permalink
Also accept the wildcard accept header for application/json
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen van den Nieuwenhuisen committed Jul 23, 2020
1 parent dbd9087 commit 3704d47
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ private function setFormTheme(FormView $formView, ?array $theme = null): void

private function handleXmlHttpRequestErrorResponse(Request $request, FormInterface $form): ?JsonResponse
{
if (!\in_array('application/json', $request->getAcceptableContentTypes(), true)) {
if (0 === \count(array_intersect(['application/json', '*/*'], $request->getAcceptableContentTypes()))) {
@trigger_error('In next major version response will return 406 NOT ACCEPTABLE without `Accept: application/json`', E_USER_DEPRECATED);

return null;
Expand All @@ -1585,7 +1585,7 @@ private function handleXmlHttpRequestErrorResponse(Request $request, FormInterfa
*/
private function handleXmlHttpRequestSuccessResponse(Request $request, $object): JsonResponse
{
if (!\in_array('application/json', $request->getAcceptableContentTypes(), true)) {
if (0 === \count(array_intersect(['application/json', '*/*'], $request->getAcceptableContentTypes()))) {
@trigger_error('In next major version response will return 406 NOT ACCEPTABLE without `Accept: application/json`', E_USER_DEPRECATED);
}

Expand Down

0 comments on commit 3704d47

Please sign in to comment.