Added processExtra to request, allows for merging application/json POST bodies into $_POST
This commit is contained in:
parent
48bf5f1e67
commit
1ae5e0b8a1
@ -83,6 +83,26 @@
|
|||||||
Request::$strResourcePath = $strPath;
|
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()
|
public static function getScript()
|
||||||
{
|
{
|
||||||
return Request::$strScriptPath;
|
return Request::$strScriptPath;
|
||||||
@ -173,4 +193,5 @@
|
|||||||
|
|
||||||
// Call this no matter what to understand the request:
|
// Call this no matter what to understand the request:
|
||||||
Request::process();
|
Request::process();
|
||||||
|
Request::processExtra();
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user