function _googleanalytics_get_http_header in Google Analytics 6.4
Emulate D7 drupal_get_http_header(). Looks a bit overkill.
1 call to _googleanalytics_get_http_header()
- googleanalytics_add_js in ./
googleanalytics.module - Adds Google Analytics tracking scripts.
File
- ./
googleanalytics.module, line 658 - Drupal Module: Google Analytics
Code
function _googleanalytics_get_http_header($name = NULL) {
$data = drupal_get_headers();
$raw_headers = preg_split('/(\\r\\n?|\\n)/', $data);
$headers = array();
foreach ($raw_headers as $raw_header) {
// Header: HTTP/1.1 404 Not Found
if (preg_match('/^(HTTP\\/\\d.\\d+)\\s(\\w+)/', $raw_header)) {
$status = preg_replace('/^(HTTP\\/\\d.\\d+)\\s/', '', $raw_header);
$headers['Status'] = $status;
continue;
}
list($header, $value) = explode(':', $raw_header);
$headers[trim($header)] = trim($value);
}
if (isset($name)) {
return isset($headers[$name]) ? $headers[$name] : NULL;
}
else {
return $headers;
}
}