Skip to content

Commit

Permalink
Merge pull request #3 from joubertredrat/bugfix/methods-vs-content-type
Browse files Browse the repository at this point in the history
Fix on validate method with no body
  • Loading branch information
joubertredrat authored Jul 8, 2020
2 parents 90827aa + c797276 commit 0ae55f5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/EventListener/RequestApiListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ private function getMethodsNoBody(): array

private function isValidBodyData(Request $request): bool
{
if ("" === $request->getContent()) {
return true;
}

json_decode($request->getContent(), true);

return JSON_ERROR_NONE == json_last_error();
Expand All @@ -106,6 +110,10 @@ private function getResponse(

private function convertData(Request $request): void
{
if ("" === $request->getContent()) {
return;
}

$jsonData = json_decode($request->getContent(), true);

if ($jsonData) {
Expand Down

0 comments on commit 0ae55f5

Please sign in to comment.