diff --git a/CHANGELOG.md b/CHANGELOG.md index 4431d0cd5..2576e0eb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.5.0-rc.2 +## mm/dd/2018 + +1. [](#new) + * Added `Uri::method()` to get current HTTP method (GET/POST etc) + # v1.5.0-rc.1 ## 07/31/2018 diff --git a/index.php b/index.php index 96ca67a1a..db077f5eb 100644 --- a/index.php +++ b/index.php @@ -15,7 +15,7 @@ if (!is_file($autoload)) { die("Please run: bin/grav install"); } -if (PHP_SAPI == 'cli-server') { +if (PHP_SAPI === 'cli-server') { if (!isset($_SERVER['PHP_CLI_ROUTER'])) { die("PHP webserver requires a router to run Grav, please use:
php -S {$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']} system/router.php
"); } diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index 9bfdf37d1..b17323926 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -371,6 +371,17 @@ class Uri return $this->extension; } + public function method() + { + $method = isset($_SERVER['REQUEST_METHOD']) ? strtoupper($_SERVER['REQUEST_METHOD']) : 'GET'; + + if ($method === 'POST' && isset($_SERVER['X-HTTP-METHOD-OVERRIDE'])) { + $method = strtoupper($_SERVER['X-HTTP-METHOD-OVERRIDE']); + } + + return $method; + } + /** * Return the scheme of the URI * @@ -620,10 +631,9 @@ class Uri } return $ip; - } - /** + /** * Returns current Uri. * * @return \Grav\Framework\Uri\Uri