summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-03-06 06:31:24 +0000
committerDries Buytaert <dries@buytaert.net>2010-03-06 06:31:24 +0000
commite1ce11dad0bb6377ffddaa5fb0b7174e406ba20c (patch)
tree6cdf49084a28fba8c6910a7e000f6708888858a4 /includes
parent140cacba103e3241d24d24c8c1d06c760280261b (diff)
downloadbrdo-e1ce11dad0bb6377ffddaa5fb0b7174e406ba20c.tar.gz
brdo-e1ce11dad0bb6377ffddaa5fb0b7174e406ba20c.tar.bz2
- Patch #732486 by Damien Tournoud, JacobSingh: drupal_add_http_header() req ; make Status a normal header and drupal_add_http() header shouldn't return a list of headers.
Diffstat (limited to 'includes')
-rw-r--r--includes/bootstrap.inc30
-rw-r--r--includes/common.inc6
-rw-r--r--includes/database/database.inc2
-rw-r--r--includes/errors.inc2
4 files changed, 15 insertions, 25 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 9a1691fb1..c263fbe50 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -906,32 +906,22 @@ function drupal_load($type, $name) {
* too. This is necessary to avoid security bugs (e.g. UTF-7 XSS).
*
* @param $name
- * The HTTP header name, or a status code followed by a reason phrase, e.g.
- * "404 Not Found".
+ * The HTTP header name, or the special 'Status' header name.
* @param $value
- * The HTTP header value; if omitted, the specified header is unset.
+ * 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".
* @param $append
* Whether to append the value to an existing header or to replace it.
*/
-function drupal_add_http_header($name = NULL, $value = NULL, $append = FALSE) {
+function drupal_add_http_header($name, $value, $append = FALSE) {
// The headers as name/value pairs.
- $headers = &drupal_static(__FUNCTION__, array());
+ $headers = &drupal_static('drupal_http_headers', array());
- if (!isset($name)) {
- return $headers;
- }
-
- // Save status codes using the special key ":status".
- if (preg_match('/^\d{3} /', $name)) {
- $value = $name;
- $name = $name_lower = ':status';
- }
- else {
- $name_lower = strtolower($name);
- }
+ $name_lower = strtolower($name);
_drupal_set_preferred_header_name($name);
- if (!isset($value)) {
+ if ($value === FALSE) {
$headers[$name_lower] = FALSE;
}
elseif (isset($headers[$name_lower]) && $append) {
@@ -956,7 +946,7 @@ function drupal_add_http_header($name = NULL, $value = NULL, $append = FALSE) {
* or NULL if the header has not been set.
*/
function drupal_get_http_header($name = NULL) {
- $headers = drupal_add_http_header();
+ $headers = &drupal_static('drupal_http_headers', array());
if (isset($name)) {
$name = strtolower($name);
return isset($headers[$name]) ? $headers[$name] : NULL;
@@ -1006,7 +996,7 @@ function drupal_send_headers($default_headers = array(), $only_default = FALSE)
}
}
foreach ($headers as $name_lower => $value) {
- if ($name_lower == ':status') {
+ if ($name_lower == 'status') {
header($_SERVER['SERVER_PROTOCOL'] . ' ' . $value);
}
// Skip headers that have been unset.
diff --git a/includes/common.inc b/includes/common.inc
index e9b8180db..b90618198 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -2339,7 +2339,7 @@ function drupal_deliver_html_page($page_callback_result) {
switch ($page_callback_result) {
case MENU_NOT_FOUND:
// Print a 404 page.
- drupal_add_http_header('404 Not Found');
+ drupal_add_http_header('Status', '404 Not Found');
watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
@@ -2369,7 +2369,7 @@ function drupal_deliver_html_page($page_callback_result) {
case MENU_ACCESS_DENIED:
// Print a 403 page.
- drupal_add_http_header('403 Forbidden');
+ drupal_add_http_header('Status', '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.
@@ -2397,7 +2397,7 @@ function drupal_deliver_html_page($page_callback_result) {
case MENU_SITE_OFFLINE:
// Print a 503 page.
drupal_maintenance_theme();
- drupal_add_http_header('503 Service unavailable');
+ drupal_add_http_header('Status', '503 Service unavailable');
drupal_set_title(t('Site under maintenance'));
print theme('maintenance_page', array('content' => 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')))))));
diff --git a/includes/database/database.inc b/includes/database/database.inc
index b381ac72b..e11129136 100644
--- a/includes/database/database.inc
+++ b/includes/database/database.inc
@@ -2722,7 +2722,7 @@ function _db_error_page($error = '') {
global $db_type;
drupal_language_initialize();
drupal_maintenance_theme();
- drupal_add_http_header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
+ drupal_add_http_header('Status', '503 Service Unavailable');
drupal_set_title('Site offline');
}
diff --git a/includes/errors.inc b/includes/errors.inc
index 39fb48be9..4ed7115e4 100644
--- a/includes/errors.inc
+++ b/includes/errors.inc
@@ -172,7 +172,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
}
if ($fatal) {
- drupal_add_http_header('500 Service unavailable (with message)');
+ drupal_add_http_header('Status', '500 Service unavailable (with message)');
}
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {