drupal_send_headers

Versions
7
drupal_send_headers($default_headers = array(), $only_default = FALSE)

Send the HTTP response headers previously set using drupal_add_http_header(). Add default headers, unless they have been replaced or unset using drupal_add_http_header().

Parameters

$default_headers An array of headers as name/value pairs.

$single If TRUE and headers have already be sent, send only the specified header.

▾ 4 functions call drupal_send_headers()

drupal_add_http_header in includes/bootstrap.inc
Set an HTTP response header for the current page.
drupal_page_header in includes/bootstrap.inc
Set HTTP headers in preparation for a page response.
drupal_serve_page_from_cache in includes/bootstrap.inc
Set HTTP headers in preparation for a cached page response.
file_transfer in includes/file.inc
Transfer file using HTTP to client. Pipes a file through Drupal to the client.

Code

includes/bootstrap.inc, line 965

<?php
function drupal_send_headers($default_headers = array(), $only_default = FALSE) {
  $headers_sent = &drupal_static(__FUNCTION__, FALSE);
  $headers = drupal_get_http_header();
  if ($only_default && $headers_sent) {
    $headers = array();
  }
  $headers_sent = TRUE;

  $header_names = _drupal_set_preferred_header_name();
  foreach ($default_headers as $name => $value) {
    $name_lower = strtolower($name);
    if (!isset($headers[$name_lower])) {
      $headers[$name_lower] = $value;
      $header_names[$name_lower] = $name;
    }
  }
  foreach ($headers as $name_lower => $value) {
    if ($name_lower == ':status') {
      header($_SERVER['SERVER_PROTOCOL'] . ' ' . $value);
    }
    // Skip headers that have been unset.
    elseif ($value) {
      header($header_names[$name_lower] . ': ' . $value);
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.