? beautify-484756.patch
Index: beautify.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/beautify/beautify.module,v
retrieving revision 1.3.2.5
diff -u -p -r1.3.2.5 beautify.module
--- beautify.module	1 Feb 2009 12:15:18 -0000	1.3.2.5
+++ beautify.module	10 Nov 2009 04:55:49 -0000
@@ -56,7 +56,7 @@ function beautify_settings() {
     '#type' => 'checkbox',
     '#title' => t('Enable output processing'),
     '#default_value' => variable_get('beautify_enabled', 1),
-  );  
+  );
   $form['beautify_method'] = array(
     '#type' => 'radios',
     '#title' => t('Method'),
@@ -271,7 +271,7 @@ function beautify_init() {
 
 /**
  * Flush the output buffer and send the contents to the router for processing.
- * 
+ *
  * This hook will run Tidy twice if debug mode is enabled to get the line
  * numbers right on debug messages (this is highly recommendeded if the site
  * has enough CPU power).
@@ -308,6 +308,10 @@ function beautify_router($input) {
     print $input;
     return;
   }
+  if (boost_headers_contain('gzip')) {
+    $input = gzinflate(substr(substr($input, 10), 0, -8));
+  }
+
   $processor = variable_get('beautify_method', 'builtin');
   $mode = variable_get('beautify_mode', 2);
   switch ($processor) {
@@ -322,37 +326,13 @@ function beautify_router($input) {
       break;
   }
 
-  beautify_set_cache($output);
+  ob_start();
+//   if (boost_headers_contain('gzip')) {
+//     $output = gzencode($output, 9);
+//   }
   print $output;
-}
-
-/**
- * Set the processed HTML to the page cache.
- *
- * This attempts to override the page_set_cache(). There could be a better way
- * to do this. Suggestions welcome!
- */
-function beautify_set_cache($input) {
-  global $user, $base_root;
-  if (!$user->uid && $_SERVER['REQUEST_METHOD'] == 'GET' && page_get_cache(TRUE)) {
-    // This will fail in some cases, see page_get_cache() for the explanation.
-    $cache = TRUE;
-    if (variable_get('page_compression', TRUE) && function_exists('gzencode')) {
-      // We do not store the data in case the zlib mode is deflate.
-      // This should be rarely happening.
-      if (zlib_get_coding_type() == 'deflate') {
-        $cache = FALSE;
-      }
-      else if (zlib_get_coding_type() == FALSE) {
-        $input = gzencode($input, 9, FORCE_GZIP);
-      }
-      // The remaining case is 'gzip' which means the data is
-      // already compressed and nothing left to do but to store it.
-    }
-
-    if ($cache && $input) {
-      cache_set($base_root . request_uri(), $input, 'cache_page', CACHE_TEMPORARY, drupal_get_headers());
-    }
+  if (variable_get('cache', CACHE_DISABLED) != CACHE_DISABLED) {
+    page_set_cache();
   }
 }
 
@@ -525,7 +505,7 @@ function beautify_htmltidy_run($input, $
 /**
  * Calculates a valid path to the HTML Tidy binary.
  *
- * @param $message 
+ * @param $message
  *   Assigned to an explanation.
  * @return
  *   TRUE if found,
@@ -554,7 +534,7 @@ function beautify_htmltidy_test(&$messag
 			$path = $new_path;
 			$test = TRUE;
 		}
-		else {	
+		else {
 			$message .= t('Could not find HTML Tidy binary.');
 		}
 	}
@@ -565,7 +545,7 @@ function beautify_htmltidy_test(&$messag
 	    return TRUE;
 	  }
 	  else {
-	    $message .= t('Found an HTML Tidy binary but it didn\'t seem to run properly. !command failed to respond correctly.', 
+	    $message .= t('Found an HTML Tidy binary but it didn\'t seem to run properly. !command failed to respond correctly.',
 	                  array('!command' => $command));
 	    return FALSE;
 	  }
@@ -609,7 +589,7 @@ function beautify_parse_html($input) {
     $head = str_replace($replace, "\n", $head);
     $output->head = $head ."\n";
   }
-  
+
   // body
   $regex = '@<body(.*)>(.*)</body\\s*>@Umsi'; // the whole body section
   preg_match($regex, $input, $matches);
