Skip to content

Commit 2abeb2c

Browse files
committed
fix: ensure HTTP verb is lower case
HTTP verb in Router must be lower case.
1 parent 7ffb6fd commit 2abeb2c

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

system/Router/AutoRouterImproved.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function __construct(// @phpstan-ignore-line
111111
*/
112112
public function getRoute(string $uri, string $httpVerb): array
113113
{
114-
$defaultMethod = $httpVerb . ucfirst($this->defaultMethod);
114+
$defaultMethod = strtolower($httpVerb) . ucfirst($this->defaultMethod);
115115
$this->method = $defaultMethod;
116116

117117
$segments = explode('/', $uri);

system/Router/RouteCollection.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class RouteCollection implements RouteCollectionInterface
150150
/**
151151
* The current method that the script is being called by.
152152
*
153-
* @var string
153+
* @var string HTTP verb (lower case) or `*`
154154
*/
155155
protected $HTTPVerb = '*';
156156

@@ -550,11 +550,13 @@ public function getHTTPVerb(): string
550550
* Sets the current HTTP verb.
551551
* Used primarily for testing.
552552
*
553+
* @param string $verb HTTP verb (lower case)
554+
*
553555
* @return $this
554556
*/
555557
public function setHTTPVerb(string $verb)
556558
{
557-
$this->HTTPVerb = $verb;
559+
$this->HTTPVerb = strtolower($verb);
558560

559561
return $this;
560562
}

system/Router/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function __construct(RouteCollectionInterface $routes, ?Request $request
126126
$this->controller = $this->collection->getDefaultController();
127127
$this->method = $this->collection->getDefaultMethod();
128128

129-
$this->collection->setHTTPVerb(strtolower($request->getMethod() ?? $_SERVER['REQUEST_METHOD']));
129+
$this->collection->setHTTPVerb($request->getMethod() ?? $_SERVER['REQUEST_METHOD']);
130130

131131
$this->translateURIDashes = $this->collection->shouldTranslateURIDashes();
132132

0 commit comments

Comments
 (0)