From 3fcedb55ef34d4615eef9a3526819cb049cf1036 Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 28 Mar 2024 23:22:39 +0000 Subject: [PATCH] Alternative attempt at support HEAD requests. --- src/Http/Routing/HttpRouter.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Http/Routing/HttpRouter.php b/src/Http/Routing/HttpRouter.php index 4e100e7..e44fa87 100644 --- a/src/Http/Routing/HttpRouter.php +++ b/src/Http/Routing/HttpRouter.php @@ -113,6 +113,9 @@ class HttpRouter implements IRouter { if(trim($method) !== $method) throw new InvalidArgumentException('$method may start or end with whitespace'); + if($method === 'GET') + $this->add('HEAD', $path, $handler); + $prepared = self::preparePath($path, false); if($prepared === false) { if(str_ends_with($path, '/')) @@ -131,8 +134,6 @@ class HttpRouter implements IRouter { } public function resolve(string $method, string $path): ResolvedRouteInfo { - if($method === 'head') - $method = 'get'; if(str_ends_with($path, '/')) $path = substr($path, 0, -1);