diff --git a/EventListener/BodyListener.php b/EventListener/BodyListener.php index cdf0e80b9..585f436f7 100644 --- a/EventListener/BodyListener.php +++ b/EventListener/BodyListener.php @@ -76,7 +76,7 @@ public function onKernelRequest(RequestEvent $event): void if (null === $format || !$this->decoderProvider->supports($format)) { if ($this->throwExceptionOnUnsupportedContentType - && $this->isNotAnEmptyDeleteRequestWithNoSetContentType($method, $content, $contentType) + && $this->isNotAnEmptyPostOrDeleteRequestWithNoSetContentType($method, $content, $contentType) ) { throw new UnsupportedMediaTypeHttpException("Request body format '$format' not supported"); } @@ -109,9 +109,9 @@ public function onKernelRequest(RequestEvent $event): void } } - private function isNotAnEmptyDeleteRequestWithNoSetContentType(string $method, $content, ?string $contentType): bool + private function isNotAnEmptyPostOrDeleteRequestWithNoSetContentType(string $method, $content, ?string $contentType): bool { - return false === ('DELETE' === $method && empty($content) && empty($contentType)); + return false === (in_array($method, ['DELETE', 'POST'], true) && empty($content) && empty($contentType)); } private function isDecodeable(Request $request): bool