Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions EventListener/BodyListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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
Expand Down