diff options
author | Andrey Andreev <narf@devilix.net> | 2013-04-18 13:02:56 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2013-04-18 13:02:56 +0200 |
commit | b0639fa1cd0a06d9350767be3d620276e587e6ea (patch) | |
tree | d2d3491e7c5f6381d23713a29ecbc56c3228b40c /system | |
parent | 31da423ebba877984675e7232f100842d58b6dfc (diff) | |
parent | 8347f9161a1ba080be62b22eb546cceea8f8a8e9 (diff) |
Merge pull request #2409 from chernjie/develop
apache_request_headers need not go through recapitalization of incoming headers
Diffstat (limited to 'system')
-rw-r--r-- | system/core/Input.php | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/system/core/Input.php b/system/core/Input.php index 6690b7f2e..0ef81128e 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -790,31 +790,30 @@ class CI_Input { */ public function request_headers($xss_clean = FALSE) { + // If header is already defined, return it immediately + if ( ! empty($this->headers)) + { + return $this->headers; + } + // In Apache, you can simply call apache_request_headers() if (function_exists('apache_request_headers')) { - $headers = apache_request_headers(); + return $this->headers = apache_request_headers(); } - else - { - $headers['Content-Type'] = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE'); - foreach ($_SERVER as $key => $val) - { - if (sscanf($key, 'HTTP_%s', $header) === 1) - { - $headers[$header] = $this->_fetch_from_array($_SERVER, $key, $xss_clean); - } - } - } + $this->headers['Content-Type'] = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE'); - // take SOME_HEADER and turn it into Some-Header - foreach ($headers as $key => $val) + foreach ($_SERVER as $key => $val) { - $key = str_replace(array('_', '-'), ' ', strtolower($key)); - $key = str_replace(' ', '-', ucwords($key)); + if (sscanf($key, 'HTTP_%s', $header) === 1) + { + // take SOME_HEADER and turn it into Some-Header + $header = str_replace('_', ' ', strtolower($header)); + $header = str_replace(' ', '-', ucwords($header)); - $this->headers[$key] = $val; + $this->headers[$header] = $this->_fetch_from_array($_SERVER, $key, $xss_clean); + } } return $this->headers; |