Skip to content

Commit

Permalink
Fix reading form data when requests set to form-data in postman
Browse files Browse the repository at this point in the history
  • Loading branch information
gigili committed May 4, 2024
1 parent 17a56a9 commit b5207f3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function __construct()
}
}

if(is_string($input) && str_contains($input, "Content-Disposition")){
$input = $this->parse_raw_form_data($input);
if ( is_array($input) && str_contains(array_keys($input)[0], "Content-Disposition") ) {
$input = $this->parse_raw_form_data();
}

$_REQUEST = array_merge($_REQUEST, (array)$input);
Expand Down Expand Up @@ -255,10 +255,12 @@ private function parse_patch_and_put_request_data(): array
*
* @return array Returns parsed raw form data into an array
*/
private function parse_raw_form_data($input): array
private function parse_raw_form_data(): array
{
$a_data = [];

$input = file_get_contents('php://input');

// grab multipart boundary from content type header
preg_match('/boundary=(.*)$/', $_SERVER['CONTENT_TYPE'], $matches);
$boundary = $matches[1];
Expand Down

0 comments on commit b5207f3

Please sign in to comment.