Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.800
diff -u -p -r1.800 common.inc
--- includes/common.inc	6 Oct 2008 11:07:14 -0000	1.800
+++ includes/common.inc	7 Oct 2008 22:56:59 -0000
@@ -137,7 +137,7 @@ function drupal_set_header($header = NUL
   // ends HTTP headers prematurely on some PHP versions.
   static $stored_headers = array();
 
-  if (strlen($header)) {
+  if (strlen($header) && !headers_sent()) {
     header($header);
     $stored_headers[] = $header;
   }
