From 1c7f089dea266a8555da539b6924d566cfd2c0e9 Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Thu, 30 Nov 2006 08:13:31 +0000 Subject: [PATCH] #75803: Allow other HTTP status codes in drupal_goto() --- includes/common.inc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/includes/common.inc b/includes/common.inc index 6724e2b5b39..c5eca4a2ba3 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -282,10 +282,20 @@ function drupal_get_destination() { * The query string component, if any. * @param $fragment * The destination fragment identifier (named anchor). - * + * @param $http_response_code + * Valid values for an actual "goto" as per RFC 2616 section 10.3 are: + * - 301 Moved Permanently (the recommended value for most redirects) + * - 302 Found (default in Drupal and PHP, sometimes used for spamming search + * engines) + * - 303 See Other + * - 304 Not Modified + * - 305 Use Proxy + * - 307 Temporary Redirect (an alternative to "503 Site Down for Maintenance") + * Note: Other values are defined by RFC 2616, but are rarely used and poorly + * supported. * @see drupal_get_destination() */ -function drupal_goto($path = '', $query = NULL, $fragment = NULL) { +function drupal_goto($path = '', $query = NULL, $fragment = NULL, $http_response_code = 302) { if (isset($_REQUEST['destination'])) { extract(parse_url(urldecode($_REQUEST['destination']))); } @@ -298,7 +308,7 @@ function drupal_goto($path = '', $query = NULL, $fragment = NULL) { // Before the redirect, allow modules to react to the end of the page request. module_invoke_all('exit', $url); - header('Location: '. $url); + header('Location: '. $url, TRUE, $http_response_code); // The "Location" header sends a REDIRECT status code to the http // daemon. In some cases this can go wrong, so we make sure none