Added processExtra to request, allows for merging application/json POST bodies into $_POST

This commit is contained in:
Conner Harkness 2025-08-14 14:43:23 -06:00
parent 48bf5f1e67
commit 1ae5e0b8a1

View File

@ -83,6 +83,26 @@
Request::$strResourcePath = $strPath;
}
public static function processExtra()
{
$strInput = file_get_contents("php://input");
$strContentType = Request::getHeader("Content-Type");
switch ($strContentType)
{
// Allow posted JSON bodies to be merged with $_POST:
case "application/json":
if ($strInput !== null && strlen($strInput) > 0)
{
$o = json_decode($strInput, true);
foreach ($o as $k => $v)
$_POST[$k] = $v;
}
break;
}
}
public static function getScript()
{
return Request::$strScriptPath;
@ -173,4 +193,5 @@
// Call this no matter what to understand the request:
Request::process();
Request::processExtra();
?>