function drupal_add_http_header
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).
Parameters
$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.
File
- includes/bootstrap.inc, line 1383
- Functions that need to be loaded on every Drupal request.
Code
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); _drupal_set_preferred_header_name($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; } drupal_send_headers(array($name => $headers[$name_lower]), TRUE); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_add_http_header/7.x