function drupal_add_http_header

8.x drupal_add_http_header($name, $value, $append = FALSE)

Sets an HTTP response header for the current page.

Note: When sending a Content-Type header, always include a 'charset' type, too. This is necessary to avoid security bugs (e.g. UTF-7 XSS).


$name: The HTTP header name, or the special 'Status' header name.

$value: The HTTP header value; if equal to FALSE, the specified header is unset. If $name is 'Status', this is expected to be a status code followed by a reason phrase, e.g. "404 Not Found".

$append: Whether to append the value to an existing header or to replace it.


Header handling is being shifted to a Symfony response object.

8 calls to drupal_add_http_header()
authorize_access_denied_page in drupal/core/authorize.php
Renders a 403 access denied page for authorize.php.
drupal_serve_page_from_cache in drupal/core/includes/
Sets HTTP headers in preparation for a cached page response.
image_style_deliver in drupal/core/modules/image/image.module
Page callback: Generates a derivative, given a style and image path.
system_test_set_header in drupal/core/modules/system/tests/modules/system_test/system_test.module
theme_install_page in drupal/core/includes/
Returns HTML for the installation page.

... See full list

2 string references to 'drupal_add_http_header'
drupal_add_html_head_link in drupal/core/includes/
Adds a LINK tag with a distinct 'rel' attribute to the page's HEAD.
_drupal_default_html_head in drupal/core/includes/
Returns elements that are always displayed in the HEAD tag of the HTML page.


drupal/core/includes/, line 1075
Functions that need to be loaded on every Drupal request.


function drupal_add_http_header($name, $value, $append = FALSE) {
  // The headers as name/value pairs.
  $headers = &drupal_static('drupal_http_headers', array());

  $name_lower = strtolower($name);

  if ($value === FALSE) {
    $headers[$name_lower] = FALSE;
  elseif (isset($headers[$name_lower]) && $append) {
    // Multiple headers with identical names may be combined using comma (RFC
    // 2616, section 4.2).
    $headers[$name_lower] .= ',' . $value;
  else {
    $headers[$name_lower] = $value;