Skip to content

Commit 8178bda

Browse files
authored
Merge pull request #5963 from kenjis/refactor-Request-getMethod-with-strtolower
refactor: add strtolower() to Request::getMethod()
2 parents bebeedd + bc2dea2 commit 8178bda

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

app/Views/errors/html/error_exception.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
</tr>
200200
<tr>
201201
<td>HTTP Method</td>
202-
<td><?= esc($request->getMethod(true)) ?></td>
202+
<td><?= esc(strtoupper($request->getMethod())) ?></td>
203203
</tr>
204204
<tr>
205205
<td>IP Address</td>

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/Debug/Toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function run(float $startTime, float $totalTime, RequestInterface $reques
7676
{
7777
// Data items used within the view.
7878
$data['url'] = current_url();
79-
$data['method'] = $request->getMethod(true);
79+
$data['method'] = strtoupper($request->getMethod());
8080
$data['isAJAX'] = $request->isAJAX();
8181
$data['startTime'] = $startTime;
8282
$data['totalTime'] = $totalTime * 1000;

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)