Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CLI override for HTTPVerb
Browse files Browse the repository at this point in the history
CodeIgniter.php sets the request method on `request` or `clirequest` service, so RouteCollection needs to check the proper service to get the correct HTTPVerb to account for CLI, spoofing, and standard scenarios.
See codeigniter4#2021
MGatner authored May 22, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent d478c94 commit def573f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
@@ -234,8 +234,11 @@ class RouteCollection implements RouteCollectionInterface
*/
public function __construct(FileLocator $locator, $moduleConfig)
{
// Load the correct request service
$request = (is_cli() && ! (ENVIRONMENT === 'testing')) ? Services::clirequest() : Services::request();

// Get HTTP verb from current request (accounts for spoofing)
$this->HTTPVerb = Services::request()->getMethod();
$this->HTTPVerb = $request->getMethod();

$this->fileLocator = $locator;

0 comments on commit def573f

Please sign in to comment.