From 48bf5f1e67a50ef527e8e3a1ddf42ced8d2809d6 Mon Sep 17 00:00:00 2001 From: Conner Harkness Date: Thu, 14 Aug 2025 10:26:23 -0600 Subject: [PATCH] Added convenience function to read from header --- lib/Request.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/Request.php b/lib/Request.php index b794c2c..05a9970 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -125,6 +125,22 @@ return null; } + public static function getHeader($strKey) + { + if (is_array($_SERVER)) + { + $strHeaderKey = "HTTP_{$strKey}"; + $strHeaderKey = strtoupper($strHeaderKey); + $strHeaderKey = preg_replace("/\-/", "_", $strHeaderKey); + + if (array_key_exists($strHeaderKey, $_SERVER)) + if (strlen($_SERVER[$strHeaderKey]) > 0) + return $_SERVER[$strHeaderKey]; + } + + return null; + } + // Returns true if all of the arguments are in the POST request // To be used like: // if (Request::posts("param1", "param2")) {