From 1a9351c69097ed58e9bd0152bf550152d4452e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Sun, 1 May 2016 00:02:42 +0200 Subject: [PATCH] - Fixed notifications if included in projects running in command-line where certain variables aren't available. --- src/Pecee/Http/Input/Input.php | 2 +- src/Pecee/Http/Request.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Pecee/Http/Input/Input.php b/src/Pecee/Http/Input/Input.php index 688de6a..bdbb7a4 100644 --- a/src/Pecee/Http/Input/Input.php +++ b/src/Pecee/Http/Input/Input.php @@ -123,7 +123,7 @@ class Input { $postVars = array(); - if(in_array($_SERVER['REQUEST_METHOD'], ['PUT', 'PATCH', 'DELETE'])) { + if(isset($_SERVER['REQUEST_METHOD']) && in_array($_SERVER['REQUEST_METHOD'], ['PUT', 'PATCH', 'DELETE'])) { parse_str(file_get_contents('php://input'), $postVars); } else { $postVars = $_POST; diff --git a/src/Pecee/Http/Request.php b/src/Pecee/Http/Request.php index 9b589cd..5f04a5e 100644 --- a/src/Pecee/Http/Request.php +++ b/src/Pecee/Http/Request.php @@ -22,9 +22,9 @@ class Request { public function __construct() { $this->data = array(); - $this->host = $_SERVER['HTTP_HOST']; - $this->uri = $_SERVER['REQUEST_URI']; - $this->method = (isset($_POST['_method'])) ? strtolower($_POST['_method']) : strtolower($_SERVER['REQUEST_METHOD']); + $this->host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : array(); + $this->uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : array(); + $this->method = (isset($_POST['_method'])) ? strtolower($_POST['_method']) : (isset($_SERVER['REQUEST_METHOD']) ? strtolower($_SERVER['REQUEST_METHOD']) : array()); $this->headers = $this->getAllHeaders(); $this->input = new Input(); }