Alternative attempt at support HEAD requests.

This commit is contained in:
flash 2024-03-28 23:22:39 +00:00
parent 0472625a00
commit 3fcedb55ef

View file

@ -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);