From 1ae5e0b8a1a006fb5abacb1a9cecfdca8602f196 Mon Sep 17 00:00:00 2001 From: Conner Harkness Date: Thu, 14 Aug 2025 14:43:23 -0600 Subject: [PATCH] Added processExtra to request, allows for merging application/json POST bodies into $_POST --- lib/Request.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/Request.php b/lib/Request.php index 05a9970..79fab27 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -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(); ?>