Commit 7178f6b1 authored by Dries's avatar Dries

- Patch #451604 by brianV, sun | Dries, c960657: rename drupal_set_header().

parent a8f8a26f
......@@ -843,7 +843,7 @@ function drupal_load($type, $name) {
* @param $append
* Whether to append the value to an existing header or to replace it.
*/
function drupal_set_header($name = NULL, $value = NULL, $append = FALSE) {
function drupal_add_http_header($name = NULL, $value = NULL, $append = FALSE) {
// The headers as name/value pairs.
$headers = &drupal_static(__FUNCTION__, array());
......@@ -885,8 +885,8 @@ function drupal_set_header($name = NULL, $value = NULL, $append = FALSE) {
* A string containing the header value, or FALSE if the header has been set,
* or NULL if the header has not been set.
*/
function drupal_get_header($name = NULL) {
$headers = drupal_set_header();
function drupal_get_http_header($name = NULL) {
$headers = drupal_add_http_header();
if (isset($name)) {
$name = strtolower($name);
return isset($headers[$name]) ? $headers[$name] : NULL;
......@@ -910,9 +910,9 @@ function _drupal_set_preferred_header_name($name = NULL) {
}
/**
* Send the HTTP response headers previously set using drupal_set_header().
* Send the HTTP response headers previously set using drupal_add_http_header().
* Add default headers, unless they have been replaced or unset using
* drupal_set_header().
* drupal_add_http_header().
*
* @param $default_headers
* An array of headers as name/value pairs.
......@@ -921,7 +921,7 @@ function _drupal_set_preferred_header_name($name = NULL) {
*/
function drupal_send_headers($default_headers = array(), $only_default = FALSE) {
$headers_sent = &drupal_static(__FUNCTION__, FALSE);
$headers = drupal_get_header();
$headers = drupal_get_http_header();
if ($only_default && $headers_sent) {
$headers = array();
}
......@@ -994,7 +994,7 @@ function drupal_page_header() {
*
* The headers allow as much as possible in proxies and browsers without any
* particular knowledge about the pages. Modules can override these headers
* using drupal_set_header().
* using drupal_add_http_header().
*
* If the request is conditional (using If-Modified-Since and If-None-Match),
* and the conditions match those currently in the cache, a 304 Not Modified
......@@ -1006,10 +1006,10 @@ function drupal_serve_page_from_cache(stdClass $cache) {
$return_compressed = $page_compression && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE;
// Get headers set in hook_boot(). Keys are lower-case.
$hook_boot_headers = drupal_get_header();
$hook_boot_headers = drupal_get_http_header();
// Headers generated in this function, that may be replaced or unset using
// drupal_set_headers(). Keys are mixed-case.
// drupal_add_http_headers(). Keys are mixed-case.
$default_headers = array();
foreach ($cache->headers as $name => $value) {
......@@ -1018,7 +1018,7 @@ function drupal_serve_page_from_cache(stdClass $cache) {
// headers set in hook_boot().
$name_lower = strtolower($name);
if (in_array($name_lower, array('content-location', 'expires', 'cache-control', 'vary')) && !isset($hook_boot_headers[$name_lower])) {
drupal_set_header($name, $value);
drupal_add_http_header($name, $value);
unset($cache->headers[$name]);
}
}
......@@ -1050,7 +1050,7 @@ function drupal_serve_page_from_cache(stdClass $cache) {
// Send the remaining headers.
foreach ($cache->headers as $name => $value) {
drupal_set_header($name, $value);
drupal_add_http_header($name, $value);
}
$default_headers['Last-Modified'] = gmdate(DATE_RFC1123, $cache->created);
......
......@@ -645,7 +645,7 @@ function drupal_goto($path = '', array $query = array(), $fragment = NULL, $http
*/
function drupal_site_offline() {
drupal_maintenance_theme();
drupal_set_header('503 Service unavailable');
drupal_add_http_header('503 Service unavailable');
drupal_set_title(t('Site under maintenance'));
print theme('maintenance_page', filter_xss_admin(variable_get('maintenance_mode_message',
t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal'))))));
......@@ -655,7 +655,7 @@ function drupal_site_offline() {
* Generates a 404 error if the request can not be handled.
*/
function drupal_not_found() {
drupal_set_header('404 Not Found');
drupal_add_http_header('404 Not Found');
watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
......@@ -687,7 +687,7 @@ function drupal_not_found() {
* Generates a 403 error if the request is not allowed.
*/
function drupal_access_denied() {
drupal_set_header('403 Forbidden');
drupal_add_http_header('403 Forbidden');
watchdog('access denied', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
// Keep old path for reference, and to allow forms to redirect to it.
......@@ -1139,7 +1139,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
}
if ($fatal) {
drupal_set_header('500 Service unavailable (with message)');
drupal_add_http_header('500 Service unavailable (with message)');
}
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
......@@ -3411,7 +3411,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) {
* callback function and each value an array of arguments. For example:
*
* @code
* $build['#attached']['drupal_set_header'] = array(
* $build['#attached']['drupal_add_http_header'] = array(
* array('Content-Type', 'application/rss+xml; charset=utf-8'),
* );
* @endcode
......@@ -3789,7 +3789,7 @@ function drupal_json_encode($var) {
*/
function drupal_json_output($var = NULL) {
// We are returning JavaScript, so tell the browser.
drupal_set_header('Content-Type', 'text/javascript; charset=utf-8');
drupal_add_http_header('Content-Type', 'text/javascript; charset=utf-8');
if (isset($var)) {
echo drupal_json_encode($var);
......@@ -3902,7 +3902,7 @@ function _drupal_bootstrap_full() {
set_exception_handler('_drupal_exception_handler');
// Emit the correct charset HTTP header.
drupal_set_header('Content-Type', 'text/html; charset=utf-8');
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
// Detect string handling method
unicode_check();
// Undo magic quotes
......@@ -3957,9 +3957,9 @@ function drupal_page_set_cache() {
);
// Restore preferred header names based on the lower-case names returned
// by drupal_get_header().
// by drupal_get_http_header().
$header_names = _drupal_set_preferred_header_name();
foreach (drupal_get_header() as $name_lower => $value) {
foreach (drupal_get_http_header() as $name_lower => $value) {
$cache->headers[$header_names[$name_lower]] = $value;
}
......
......@@ -2381,7 +2381,7 @@ function _db_error_page($error = '') {
global $db_type;
drupal_language_initialize();
drupal_maintenance_theme();
drupal_set_header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
drupal_add_http_header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
drupal_set_title('Site offline');
}
......
......@@ -1502,7 +1502,7 @@ function file_transfer($uri, $headers) {
}
foreach ($headers as $name => $value) {
drupal_set_header($name, $value);
drupal_add_http_header($name, $value);
}
drupal_send_headers();
$scheme = file_uri_scheme($uri);
......
......@@ -119,7 +119,7 @@ function theme_task_list($items, $active = NULL) {
* The page content to show.
*/
function theme_install_page($content) {
drupal_set_header('Content-Type', 'text/html; charset=utf-8');
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
// Assign content.
$variables['content'] = $content;
......@@ -176,7 +176,7 @@ function theme_install_page($content) {
*/
function theme_update_page($content, $show_messages = TRUE) {
// Set required headers.
drupal_set_header('Content-Type', 'text/html; charset=utf-8');
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
// Assign content and show message flag.
$variables['content'] = $content;
......
......@@ -106,8 +106,8 @@ function xmlrpc_server_error($error, $message = FALSE) {
function xmlrpc_server_output($xml) {
$xml = '<?xml version="1.0"?>' . "\n" . $xml;
drupal_set_header('Content-Length', strlen($xml));
drupal_set_header('Content-Type', 'text/xml');
drupal_add_http_header('Content-Length', strlen($xml));
drupal_add_http_header('Content-Type', 'text/xml');
echo $xml;
exit;
}
......
......@@ -369,7 +369,7 @@ function aggregator_page_rss() {
* @ingroup themeable
*/
function theme_aggregator_page_rss($feeds, $category = NULL) {
drupal_set_header('Content-Type', 'application/rss+xml; charset=utf-8');
drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
$items = '';
$feed_length = variable_get('feed_item_length', 'fulltext');
......@@ -429,7 +429,7 @@ function aggregator_page_opml($cid = NULL) {
* @ingroup themeable
*/
function theme_aggregator_page_opml($feeds) {
drupal_set_header('Content-Type', 'text/xml; charset=utf-8');
drupal_add_http_header('Content-Type', 'text/xml; charset=utf-8');
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<opml version=\"1.1\">\n";
......
......@@ -33,21 +33,21 @@ function aggregator_test_feed($use_last_modified = FALSE, $use_etag = FALSE) {
// Send appropriate response. We respond with a 304 not modified on either
// etag or on last modified.
if ($use_last_modified) {
drupal_set_header('Last-Modified', gmdate(DATE_RFC1123, $last_modified));
drupal_add_http_header('Last-Modified', gmdate(DATE_RFC1123, $last_modified));
}
if ($use_etag) {
drupal_set_header('ETag', $etag);
drupal_add_http_header('ETag', $etag);
}
// Return 304 not modified if either last modified or etag match.
if ($last_modified == $if_modified_since || $etag == $if_none_match) {
drupal_set_header('304 Not Modified');
drupal_add_http_header('304 Not Modified');
return;
}
// The following headers force validation of cache:
drupal_set_header('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT');
drupal_set_header('Cache-Control', 'must-revalidate');
drupal_set_header('Content-Type', 'application/rss+xml; charset=utf-8');
drupal_add_http_header('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT');
drupal_add_http_header('Cache-Control', 'must-revalidate');
drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
// Read actual feed from file.
$file_name = DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_rss091.xml';
......
......@@ -453,8 +453,8 @@ function image_style_generate() {
if (!$lock_acquired) {
// Tell client to retry again in 3 seconds. Currently no browsers are known
// to support Retry-After.
drupal_set_header('503 Service Unavailable');
drupal_set_header('Retry-After', 3);
drupal_add_http_header('503 Service Unavailable');
drupal_add_http_header('Retry-After', 3);
print t('Image generation in progress, please try again shortly.');
exit();
}
......@@ -474,7 +474,7 @@ function image_style_generate() {
}
else {
watchdog('image', 'Unable to generate the derived image located at %path.', $destination);
drupal_set_header('500 Internal Server Error');
drupal_add_http_header('500 Internal Server Error');
print t('Error generating image.');
exit();
}
......
......@@ -1908,7 +1908,7 @@ function node_feed($nids = FALSE, $channel = array()) {
$output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
$output .= "</rss>\n";
drupal_set_header('Content-Type', 'application/rss+xml; charset=utf-8');
drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
print $output;
}
......
......@@ -69,7 +69,7 @@ function openid_test_menu() {
*/
function openid_test_yadis_xrds() {
if ($_SERVER['HTTP_ACCEPT'] == 'application/xrds+xml') {
drupal_set_header('Content-Type', 'application/xrds+xml');
drupal_add_http_header('Content-Type', 'application/xrds+xml');
print '<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">
<XRD>
......@@ -89,7 +89,7 @@ function openid_test_yadis_xrds() {
* Menu callback; regular HTML page with an X-XRDS-Location HTTP header.
*/
function openid_test_yadis_x_xrds_location() {
drupal_set_header('X-XRDS-Location', url('openid-test/yadis/xrds', array('absolute' => TRUE)));
drupal_add_http_header('X-XRDS-Location', url('openid-test/yadis/xrds', array('absolute' => TRUE)));
return t('This page includes an X-RDS-Location HTTP header containing the URL of an XRDS document.');
}
......@@ -181,7 +181,7 @@ function _openid_test_endpoint_associate() {
// Respond to Relying Party in the special Key-Value Form Encoding (see OpenID
// Authentication 1.0, section 4.1.1).
drupal_set_header('Content-Type', 'text/plain');
drupal_add_http_header('Content-Type', 'text/plain');
print _openid_create_message($response);
}
......@@ -228,6 +228,6 @@ function _openid_test_endpoint_authenticate() {
// Put the signed message into the query string of a URL supplied by the
// Relying Party, and redirect the user.
drupal_set_header('Content-Type', 'text/plain');
drupal_add_http_header('Content-Type', 'text/plain');
header('Location: ' . url($_REQUEST['openid_return_to'], array('query' => $response, 'external' => TRUE)));
}
......@@ -10,8 +10,6 @@
* Implement hook_menu().
*/
function browser_test_menu() {
$items = array();
$items['browser_test/print/get'] = array(
'page callback' => 'browser_test_print_get',
'access arguments' => array('access content'),
......@@ -69,7 +67,7 @@ function browser_test_refresh_meta() {
function browser_test_refresh_header() {
if (!isset($_GET['refresh'])) {
$url = url('browser_test/refresh/header', array('absolute' => TRUE, 'query' => array('refresh' => 'true')));
drupal_set_header('Location', $url);
drupal_add_http_header('Location', $url);
return '';
}
echo 'Refresh successful';
......
......@@ -96,7 +96,7 @@ function system_test_redirect($code) {
}
function system_test_set_header() {
drupal_set_header($_GET['name'], $_GET['value']);
drupal_add_http_header($_GET['name'], $_GET['value']);
return t('The following header was set: %name: %value', array('%name' => $_GET['name'], '%value' => $_GET['value']));
}
......
......@@ -2730,7 +2730,7 @@ function theme_meta_generator_html($version = VERSION) {
* @ingroup themeable
*/
function theme_meta_generator_header($version = VERSION) {
drupal_set_header('X-Generator', 'Drupal ' . $version . ' (http://drupal.org)');
drupal_add_http_header('X-Generator', 'Drupal ' . $version . ' (http://drupal.org)');
}
/**
......@@ -2824,7 +2824,7 @@ function system_run_cron_image() {
// Output a transparent 1x1 image to the browser; required for clients not
// supporting JavaScript.
drupal_set_header('Content-Type', 'image/gif');
drupal_add_http_header('Content-Type', 'image/gif');
echo "\x47\x49\x46\x38\x39\x61\x1\x0\x1\x0\x80\xff\x0\xc0\xc0\xc0\x0\x0\x0\x21\xf9\x4\x1\x0\x0\x0\x0\x2c\x0\x0\x0\x0\x1\x0\x1\x0\x0\x2\x2\x44\x1\x0\x3b";
// Cron threshold semaphore is used to avoid errors every time the image
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment