From 452cdb491504cf5899cd9595611aa6d079fcfbad Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Fri, 2 Aug 2024 16:15:35 +0300 Subject: [PATCH] fix: minor corrections in headers_to_exclude Signed-off-by: Andrey Borysenko --- lib/Controller/ExAppProxyController.php | 6 ++++-- lib/Db/ExAppMapper.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Controller/ExAppProxyController.php b/lib/Controller/ExAppProxyController.php index 003dca6d..358c0a1a 100644 --- a/lib/Controller/ExAppProxyController.php +++ b/lib/Controller/ExAppProxyController.php @@ -249,7 +249,9 @@ private function buildHeadersWithExclude(ExApp $exApp, string $exAppRoute, array $matchesUrlPattern = preg_match('/' . $route['url'] . '/i', $exAppRoute) === 1; $matchesVerb = str_contains(strtolower($route['verb']), strtolower($this->request->getMethod())); if ($matchesUrlPattern && $matchesVerb) { - $headersToExclude = json_decode($route['headers_to_exclude'], true); + $headersToExclude = array_map(function ($headerName) { + return strtolower($headerName); + }, json_decode($route['headers_to_exclude'], true)); break; } } @@ -257,7 +259,7 @@ private function buildHeadersWithExclude(ExApp $exApp, string $exAppRoute, array return $headers; } foreach ($headers as $key => $value) { - if (in_array($key, $headersToExclude)) { + if (in_array(strtolower($key), $headersToExclude)) { unset($headers[$key]); } } diff --git a/lib/Db/ExAppMapper.php b/lib/Db/ExAppMapper.php index 41e022fc..ee3a4c2f 100644 --- a/lib/Db/ExAppMapper.php +++ b/lib/Db/ExAppMapper.php @@ -201,7 +201,7 @@ public function registerExAppRoutes(ExApp $exApp, array $routes): int { 'url' => $qb->createNamedParameter($route['url']), 'verb' => $qb->createNamedParameter($route['verb']), 'access_level' => $qb->createNamedParameter($route['access_level']), - 'headers_to_exclude' => $qb->createNamedParameter($route['headers_to_exclude']), + 'headers_to_exclude' => $qb->createNamedParameter(is_array($route['headers_to_exclude']) ? json_encode($route['headers_to_exclude']) : $route['headers_to_exclude']), ]); $count += $qb->executeStatement(); }