diff --git a/minifyhtml.module b/minifyhtml.module
index f8e1ad7810951cf656856e7109beca6401022bf9..55f2284c3d991b64618b564dd895781122eba19f 100644
--- a/minifyhtml.module
+++ b/minifyhtml.module
@@ -111,7 +111,8 @@ function minifyhtml_exit() {
     // Make sure to exclude image style images (is this even required
     // anymore??).
     // Make sure the buffer has a length.
-    if (stripos(drupal_get_http_header('content-type'), 'text/html') !== FALSE && !is_file($current_path) && ob_get_length()) {
+    $content_type = drupal_get_http_header('content-type');
+    if (!empty($content_type) && stripos($content_type, 'text/html') !== FALSE && !is_file($current_path) && ob_get_length()) {
 
       // Catch the output buffer. Converted from ob_get_clean().
       $page = ob_get_contents();