From 0633e4d467698698c8ece9b99ee2e6e0ff4e5297 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 8 Aug 2022 11:38:18 +0200 Subject: [PATCH] Add `\wcf\http\Helper` --- .../install/files/lib/http/Helper.class.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 wcfsetup/install/files/lib/http/Helper.class.php diff --git a/wcfsetup/install/files/lib/http/Helper.class.php b/wcfsetup/install/files/lib/http/Helper.class.php new file mode 100644 index 0000000000..6dec16e390 --- /dev/null +++ b/wcfsetup/install/files/lib/http/Helper.class.php @@ -0,0 +1,34 @@ + + * @package WoltLabSuite\Core\Http + * @since 6.0 + */ +final class Helper +{ + /** + * Returns whether the request's 'x-requested-with' header is equal + * to 'XMLHttpRequest'. + */ + public static function isAjaxRequest(ServerRequestInterface $request): bool + { + return $request->getHeaderLine('x-requested-with') === 'XMLHttpRequest'; + } + + /** + * Forbid creation of Helper objects. + */ + private function __construct() + { + // does nothing + } +} -- 2.20.1