[icinga-checkins] icinga.org: icinga-web/r1.7: Removed gz compression ( optional configuration possible)

git at icinga.org git at icinga.org
Thu Jun 21 14:29:19 CEST 2012


Module: icinga-web
Branch: r1.7
Commit: e36f2378905c9259602637014a833bb086afb0ad
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=e36f2378905c9259602637014a833bb086afb0ad

Author: Marius Hein <marius.hein at netways.de>
Date:   Thu Jun 21 13:40:58 2012 +0200

Removed gz compression (optional configuration possible)

refs #2660

---

 app/modules/AppKit/config/module.xml.in            |    2 +
 .../AppKit/validate/Widgets/SquishLoader.xml       |   10 ++++++-
 .../Widgets/SquishLoaderSuccessView.class.php      |   27 ++++++++++++++++++-
 3 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/app/modules/AppKit/config/module.xml.in b/app/modules/AppKit/config/module.xml.in
index 8db7f27..11f540e 100755
--- a/app/modules/AppKit/config/module.xml.in
+++ b/app/modules/AppKit/config/module.xml.in
@@ -29,6 +29,8 @@
                 <setting name="squishloader">
                     <ae:parameter name="cache_dir">%core.cache_dir%/Squished</ae:parameter>
                     <ae:parameter name="use_caching">@flag_caching@</ae:parameter>
+                    <ae:parameter name="use_gzcompress">false</ae:parameter>
+                    <ae:parameter name="gzcompress_level">2</ae:parameter>
                 </setting>
 
                 <setting name="user_preferences_default">
diff --git a/app/modules/AppKit/validate/Widgets/SquishLoader.xml b/app/modules/AppKit/validate/Widgets/SquishLoader.xml
index c5784aa..4977ebc 100644
--- a/app/modules/AppKit/validate/Widgets/SquishLoader.xml
+++ b/app/modules/AppKit/validate/Widgets/SquishLoader.xml
@@ -5,12 +5,18 @@
     parent="%core.module_dir%/AppKit/config/validators.xml"
 >
     <ae:configuration>
-        
         <validators>
            <validator class="string" name="IfNoneMatch" source="headers" required="false">
                 <argument>IF_NONE_MATCH</argument>
             </validator> 
-         
+
+            <validator class="string" name="accept_encoding" source="headers" required="true">
+                <argument>ACCEPT_ENCODING</argument>                                    
+                                                                                
+                <errors>                                                        
+                    <error>Could not validate HTTP_REFERER</error>              
+                </errors>                                                       
+            </validator> 
         </validators>
     </ae:configuration>
 </ae:configurations>
diff --git a/app/modules/AppKit/views/Widgets/SquishLoaderSuccessView.class.php b/app/modules/AppKit/views/Widgets/SquishLoaderSuccessView.class.php
index b9ff532..b11f8a1 100644
--- a/app/modules/AppKit/views/Widgets/SquishLoaderSuccessView.class.php
+++ b/app/modules/AppKit/views/Widgets/SquishLoaderSuccessView.class.php
@@ -45,8 +45,31 @@ class AppKit_Widgets_SquishLoaderSuccessView extends AppKitBaseView {
                 return "";
             }
             
-            ob_start("ob_gzhandler");
-
+            $options = AgaviConfig::get('modules.appkit.squishloader', array());
+            $gz_level = isset($options['gzcompress_level']) ? 
+                (integer)$options['gzcompress_level'] : 3;
+            $gz_use = isset($options['use_gzcompress']) ?
+                (boolean)$options['use_gzcompress'] : false;  
+            
+            if ($gz_use === true) {
+                
+                $encoding = $rd->getHeader('ACCEPT_ENCODING', false);
+                
+                if (strpos($encoding, 'gzip') !== false) {
+                    $encoding = 'gzip';
+                } elseif(strpos($encoding, 'x-gzip') !== false) {
+                    $encoding = 'x-gzip';
+                }
+                
+                if ($encoding !== false) {
+                    header('Content-Encoding: '. $encoding);
+                    $l = strlen($content);

+                    $content = gzcompress($content, 4);

+                    $content = substr($content, 0, $l);
+                    return "\x1f\x8b\x08\x00\x00\x00\x00\x00". $content;
+                }
+            }
+            
             return $content;
         }
     }





More information about the icinga-checkins mailing list