Skip to content

Commit 6927873

Browse files
committed
refactor: add strtolower() to Request::getMethod()
The $upper functionality will be removed.
1 parent 585d3ca commit 6927873

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

system/CodeIgniter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
318318

319319
$this->spoofRequestMethod();
320320

321-
if ($this->request instanceof IncomingRequest && $this->request->getMethod() === 'cli') {
321+
if ($this->request instanceof IncomingRequest && strtolower($this->request->getMethod()) === 'cli') {
322322
$this->response->setStatusCode(405)->setBody('Method Not Allowed');
323323

324324
return $this->sendResponse();
@@ -1047,7 +1047,7 @@ public function storePreviousURL($uri)
10471047
public function spoofRequestMethod()
10481048
{
10491049
// Only works with POSTED forms
1050-
if ($this->request->getMethod() !== 'post') {
1050+
if (strtolower($this->request->getMethod()) !== 'post') {
10511051
return;
10521052
}
10531053

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($request->getMethod() ?? strtolower($_SERVER['REQUEST_METHOD']));
129+
$this->collection->setHTTPVerb(strtolower($request->getMethod() ?? $_SERVER['REQUEST_METHOD']));
130130

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

system/Validation/Validation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public function withRequest(RequestInterface $request): ValidationInterface
354354
return $this;
355355
}
356356

357-
if (in_array($request->getMethod(), ['put', 'patch', 'delete'], true)
357+
if (in_array(strtolower($request->getMethod()), ['put', 'patch', 'delete'], true)
358358
&& strpos($request->getHeaderLine('Content-Type'), 'multipart/form-data') === false
359359
) {
360360
$this->data = $request->getRawInput();

0 commit comments

Comments
 (0)