From 76f0692b73f39504e3fc9cb8f399477a8f5523d7 Mon Sep 17 00:00:00 2001 From: Brook Gagnon Date: Wed, 18 Sep 2024 17:48:11 +0000 Subject: [PATCH] fix API to support apache headers --- VERSION | 2 +- api.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 81c8e30c..0ce8ff4e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.3.3-20240913 +5.3.3-20240918 diff --git a/api.php b/api.php index ecb27181..ce1b633a 100644 --- a/api.php +++ b/api.php @@ -31,6 +31,18 @@ class OBFAPI public function __construct() { + // merge in our apache headers with $_SERVER (if not already set) + if (function_exists('apache_request_headers')) { + $headers = apache_request_headers(); + foreach ($headers as $header => $value) { + $value = trim($value); + $index = 'HTTP_' . strtoupper(str_replace('-', '_', trim($header))); + if (!isset($_SERVER[$index])) { + $_SERVER[$index] = $value; + } + } + } + if (str_starts_with($_SERVER['REQUEST_URI'], '/api/v2/')) { // we have routes for this request method? find the regex pattern to match with, and variables to extract. $routes = json_decode(file_get_contents('routes.json'));