Permalink
Browse files

Changing the direct access of super globals in Cake/Network/CakeReque…

…st.php to use env() and fixed a typo.
  • Loading branch information...
burzum committed Nov 29, 2014
1 parent 43f7fcc commit e7f554cba70086ad51c8b03b8cc4bfb8b4ac6236
Showing with 7 additions and 20 deletions.
  1. +7 −20 lib/Cake/Network/CakeRequest.php
@@ -519,20 +519,7 @@ public function is($type) {
}
/**
* Gets the accept header from the current request.
*
* @return bool Returns an array of accept header values.
*/
public function getAcceptHeaders() {
$headers = array();
if (isset($_SERVER['HTTP_ACCEPT'])) {
$headers = explode(',', $_SERVER['HTTP_ACCEPT']);
}
return $headers;
}
/**
* Detects if an URL extension is present.
* Detects if a URL extension is present.
*
* @param array $detect Detector options array.
* @return bool Whether or not the request is the type you are checking.
@@ -554,7 +541,7 @@ protected function _extensionDetector($detect) {
* @return bool Whether or not the request is the type you are checking.
*/
protected function _acceptHeaderDetector($detect) {
$acceptHeaders = $this->getAcceptHeaders();
$acceptHeaders = explode(',', (string)env('HTTP_ACCEPT'));
foreach ($detect['accept'] as $header) {
if (in_array($header, $acceptHeaders)) {
return true;
@@ -571,12 +558,12 @@ protected function _acceptHeaderDetector($detect) {
*/
protected function _headerDetector($detect) {
foreach ($detect['header'] as $header => $value) {
$header = 'HTTP_' . strtoupper($header);
if (isset($_SERVER[$header])) {
if (is_callable($value)) {
return call_user_func($value, $_SERVER[$header]);
$header = env('HTTP_' . strtoupper($header));
if (!is_null($header)) {
if (!is_string($value) && !is_bool($value) && is_callable($value)) {
return call_user_func($value, $header);
}
return ($_SERVER[$header] === $value);
return ($header === $value);
}
}
return false;

0 comments on commit e7f554c

Please sign in to comment.