You are here

function http_response_headers_init in HTTP Response Headers 7

Implements hook_init().

File

./http_response_headers.module, line 52
Contains HTTP response headers.

Code

function http_response_headers_init() {

  // Exclude pages on global exclude list.
  if (http_response_headers_exclude_path()) {
    return;
  }
  $rules = http_response_headers_get_rules();
  foreach ($rules as $rule) {
    $header_value = $rule
      ->getHeaderValue();
    $header = $rule
      ->getHeader();

    // Handle custom callback cases.
    switch (strtolower($header)) {
      case 'expires':
        $header_value = http_response_headers_expires_callback($header_value);
        break;
      case 'last-modified':
        $header_value = http_response_headers_last_modified_callback($header_value);
        break;
    }

    // Set response header.
    drupal_add_http_header($header, $header_value);
  }
}