Index: modules/statistics/statistics.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.install,v
retrieving revision 1.15
diff -u -r1.15 statistics.install
--- modules/statistics/statistics.install	3 Dec 2008 19:22:09 -0000	1.15
+++ modules/statistics/statistics.install	11 Dec 2008 18:02:35 -0000
@@ -75,6 +75,13 @@
         'not null' => FALSE,
         'description' => 'Internal path to page visited (relative to Drupal root.)',
       ),
+      'http_status' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => FALSE,
+        'default' => 0,
+        'description' => 'HTTP/1.1 Status Code',
+      ),
       'url' => array(
         'type' => 'text',
         'not null' => FALSE,
@@ -111,6 +118,7 @@
     'indexes' => array(
       'accesslog_timestamp' => array('timestamp'),
       'uid' => array('uid'),
+      'http_status' => array('http_status'),
     ),
     'primary key' => array('aid'),
   );
@@ -126,3 +134,20 @@
   db_change_field($ret, 'accesslog', 'url', 'url', array('type' => 'text', 'not null' => FALSE));
   return $ret;
 }
+
+/**
+ * Add field and index for the HTTP/1.1 Status Code.
+ */
+function statistics_update_7001() {
+  $ret = array();
+  $field = array(
+    'type' => 'int',
+    'unsigned' => TRUE,
+    'not null' => FALSE,
+    'default' => 0,
+  );
+  db_add_field($ret, 'accesslog', 'http_status', $field);
+  db_add_index($ret, 'accesslog', 'http_status', array('http_status'));
+  
+  return $ret;
+}
Index: modules/statistics/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v
retrieving revision 1.288
diff -u -r1.288 statistics.module
--- modules/statistics/statistics.module	9 Dec 2008 11:30:25 -0000	1.288
+++ modules/statistics/statistics.module	11 Dec 2008 18:02:35 -0000
@@ -44,10 +44,11 @@
  */
 function statistics_exit() {
   global $user;
+  global $http_status;
 
   drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
 
-  if (variable_get('statistics_count_content_views', 0)) {
+  if ($http_status == 200 && variable_get('statistics_count_content_views', 0)) {
     // We are counting content views.
     if ((arg(0) == 'node') && is_numeric(arg(1)) && arg(2) == '') {
       // A node has been viewed, so update the node's counters.
@@ -69,6 +70,7 @@
     db_insert('accesslog')->fields(array(
       'title' => strip_tags(drupal_get_title()),
       'path' => $_GET['q'],
+      'http_status' => $http_status,
       'url' => $_SERVER['HTTP_REFERER'],
       'hostname' => ip_address(),
       'uid' => $user->uid,
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.257
diff -u -r1.257 bootstrap.inc
--- includes/bootstrap.inc	3 Dec 2008 14:51:53 -0000	1.257
+++ includes/bootstrap.inc	11 Dec 2008 18:02:34 -0000
@@ -386,6 +386,8 @@
  * Initialize variables needed for the rest of the execution.
  */
 function drupal_initialize_variables() {
+  global $http_status;
+
   if (!isset($_SERVER['HTTP_REFERER'])) {
     $_SERVER['HTTP_REFERER'] = '';
   }
@@ -403,6 +405,10 @@
   ini_set('html_errors', 0);
   // Don't escape quotes when reading files from the database, disk, etc.
   ini_set('magic_quotes_runtime', '0');
+
+  // Initalize http_status to 200.
+  // It may be changed later by drupal_not_found() or drupal_access_denied().
+  $http_status = 200;
 }
 
 /**
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.836
diff -u -r1.836 common.inc
--- includes/common.inc	9 Dec 2008 11:09:26 -0000	1.836
+++ includes/common.inc	11 Dec 2008 18:02:35 -0000
@@ -366,7 +366,10 @@
  * Generates a 404 error if the request can not be handled.
  */
 function drupal_not_found() {
+  global $http_status;
+
   drupal_set_header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
+  $http_status = 404;
 
   watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
 
@@ -396,7 +399,10 @@
  * Generates a 403 error if the request is not allowed.
  */
 function drupal_access_denied() {
+  global $http_status;
+
   drupal_set_header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
+  $http_status = 403;
   watchdog('access denied', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
 
   // Keep old path for reference.
