Skip to content

Commit

Permalink
Fix not getting request body for PATCH and PUT
Browse files Browse the repository at this point in the history
  • Loading branch information
gigili authored Sep 15, 2021
1 parent 9a7d7c6 commit 4a2d086
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ class Request
*/
public function __construct()
{
$input = json_decode(file_get_contents('php://input')) ?? [];
$rawInput = file_get_contents('php://input');

$input = json_decode($rawInput) ?? [];
if ( count($input) == 0 ) {
mb_parse_str($rawInput, $input);
}

if ( isset($_SERVER["REQUEST_METHOD"]) && $_SERVER['REQUEST_METHOD'] == 'PATCH' ) {
if ( isset($_REQUEST["parameters"]) ) {
$_REQUEST = array_merge($_REQUEST, $_REQUEST['parameters']);
Expand Down Expand Up @@ -78,4 +84,4 @@ public function send(string|array|object $output)
{
echo json_encode($output);
}
}
}

0 comments on commit 4a2d086

Please sign in to comment.