Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/utility/http_query.php
Show First 20 Lines • Show All 789 Lines • ▼ Show 20 Line(s) | |||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function getHeaders() | public function getHeaders() | ||||
{ | { | ||||
if ( function_exists('apache_request_headers') ) { | if ( function_exists('apache_request_headers') ) { | ||||
// If apache_request_headers() exists... | // If apache_request_headers() exists... | ||||
$headers = apache_request_headers(); | $headers = apache_request_headers(); | ||||
if ( $headers ) { | if ( $headers !== false ) { | ||||
return $headers; // And works... Use it | return $headers; // And works... Use it. | ||||
} | } | ||||
} | } | ||||
$headers = array(); | $headers = array(); | ||||
foreach ( array_keys($_SERVER) as $server_key ) { | $header_server_keys = array_filter(array_keys($_SERVER), function ($server_key) { | ||||
if ( substr($server_key, 0, 5) == 'HTTP_' ) { | return strpos($server_key, 'HTTP_') === 0; | ||||
$header_name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($server_key, 0, 5))))); | }); | ||||
foreach ( $header_server_keys as $server_key ) { | |||||
$header_name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($server_key, 5))))); | |||||
$headers[$header_name] = $_SERVER[$server_key]; | $headers[$header_name] = $_SERVER[$server_key]; | ||||
} | } | ||||
} | |||||
return $headers; | return $headers; | ||||
} | } | ||||
} | } |