From 17e5d41e55712fd1a1320a79f584dc3edd465905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Fri, 21 Nov 2014 18:49:36 +0100 Subject: [PATCH] Restructuring the CakeRequest::is() code and related code a little. --- lib/Cake/Network/CakeRequest.php | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index f98379eb553..8cddce0eb0b 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -500,20 +500,14 @@ public function is($type) { return false; } $detect = $this->_detectors[$type]; - if (isset($detect['env'])) { - if ($this->_environmentDetector($detect)) { - return true; - } + if (isset($detect['env']) && $this->_environmentDetector($detect)) { + return true; } - if (isset($detect['header'])) { - if ($this->_environmentDetector($detect)) { - return true; - } + if (isset($detect['header']) && $this->_environmentDetector($detect)) { + return true; } - if (isset($detect['param'])) { - if ($this->_paramDetector($detect)) { - return true; - } + if (isset($detect['param']) && $this->_paramDetector($detect)) { + return true; } if (isset($detect['callback']) && is_callable($detect['callback'])) { return call_user_func($detect['callback'], $this); @@ -528,13 +522,11 @@ public function is($type) { */ public function getAcceptHeaders() { $headers = array(); - if (function_exists('getallheaders')) { + if (isset($_SERVER['HTTP_ACCEPT'])) { + $headers = explode(',', $_SERVER['HTTP_ACCEPT']); + } elseif (function_exists('getallheaders')) { $headers = getallheaders(); $headers = explode(',', $headers['Accept']); - } else { - if (isset($_SERVER['HTTP_ACCEPT'])) { - $headers = explode(',', $_SERVER['HTTP_ACCEPT']); - } } return $headers; }