From 539357b6b2b8d8867305ceca03f92fe2da527014 Mon Sep 17 00:00:00 2001 From: Khalid Baheyeldin <kbahey@gmail.com> Date: Thu, 19 Mar 2009 16:11:26 +0000 Subject: [PATCH] #405822 Was not sending 403/404 HTTP code in the headers --- customerror.module | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/customerror.module b/customerror.module index 5e9ccdd..e479632 100644 --- a/customerror.module +++ b/customerror.module @@ -147,9 +147,6 @@ function customerror_simpletest() { drupal_get_path('module', 'customerror') . '/tests', '\.test$')); } -/** - * Implementation of hook_page(). - */ function customerror_page() { $code = arg(1); $_SESSION['destination'] = $_REQUEST['destination']; @@ -157,7 +154,12 @@ function customerror_page() { switch($code) { case 403: case 404: + // Check if we should redirect customerror_check_redirect(); + + // Make sure that we sent an appropriate header + customerror_header($code); + drupal_set_title(variable_get('customerror_'. $code .'_title', _customerror_fetch_error($code))); $output = theme('customerror', $code, variable_get('customerror_' . $code, _customerror_fetch_error($code))); $output = (variable_get('customerror_' . $code . '_php', FALSE)) ? drupal_eval($output) : $output; @@ -170,6 +172,17 @@ function customerror_page() { return $output; } +function customerror_header($code) { + switch($code) { + case 403: + drupal_set_header('HTTP/1.1 403 Forbidden'); + break; + case 404: + drupal_set_header('HTTP/1.1 404 Not Found'); + break; + } +} + /** * Themeable function */ -- GitLab