Skip to content

Commit

Permalink
fix: Fix to Processing Head and Other Request Methods
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Sep 1, 2024
1 parent 30e1ef9 commit 15f5d0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 6 additions & 8 deletions webfiori/http/APITestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,19 @@ public function callEndpoint(WebServicesManager $manager, string $requestMethod,
$apiEndpointName = $service->getName();
}
}
if ($method == RequestMethod::GET || $method == RequestMethod::DELETE) {
foreach ($parameters as $key => $val) {
$_GET[$key] = $this->parseVal($val);
}
$_GET['service'] = $apiEndpointName;
$this->unset($_GET, $parameters, $manager);
} else if ($method == RequestMethod::POST || $method == RequestMethod::PUT || $method == RequestMethod::PATCH) {
if ($method == RequestMethod::POST || $method == RequestMethod::PUT || $method == RequestMethod::PATCH) {
foreach ($parameters as $key => $val) {
$_POST[$key] = $this->parseVal($val);
}
$_POST['service'] = $apiEndpointName;
$_SERVER['CONTENT_TYPE'] = 'multipart/form-data';
$this->unset($_POST, $parameters, $manager);
} else {
$manager->process();
foreach ($parameters as $key => $val) {
$_GET[$key] = $this->parseVal($val);
}
$_GET['service'] = $apiEndpointName;
$this->unset($_GET, $parameters, $manager);
}

$retVal = $manager->readOutputStream();
Expand Down
10 changes: 7 additions & 3 deletions webfiori/http/WebServicesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -988,10 +988,14 @@ private function getAction() {
foreach ($serviceIdx as $serviceNameIndex) {
if (($reqMeth == RequestMethod::GET ||
$reqMeth == RequestMethod::DELETE ||
$reqMeth == RequestMethod::OPTIONS ||
$reqMeth == RequestMethod::PATCH) && isset($_GET[$serviceNameIndex])) {
$reqMeth == RequestMethod::CONNECT ||
$reqMeth == RequestMethod::HEAD ||
$reqMeth == RequestMethod::TRACE ||
$reqMeth == RequestMethod::OPTIONS) && isset($_GET[$serviceNameIndex])) {
$retVal = filter_var($_GET[$serviceNameIndex]);
} else if (($reqMeth == RequestMethod::POST || $reqMeth == RequestMethod::PUT) && isset($_POST[$serviceNameIndex])) {
} else if (($reqMeth == RequestMethod::POST ||
$reqMeth == RequestMethod::PUT ||
$reqMeth == RequestMethod::PATCH) && isset($_POST[$serviceNameIndex])) {
$retVal = filter_var($_POST[$serviceNameIndex]);
}
}
Expand Down

0 comments on commit 15f5d0f

Please sign in to comment.