click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r832111 - /incubator/click/trunk/click/extras/src/org/apache/click/extras/filter/PerformanceFilter.java
Date Mon, 02 Nov 2009 21:26:09 GMT
Author: sabob
Date: Mon Nov  2 21:26:08 2009
New Revision: 832111

URL: http://svn.apache.org/viewvc?rev=832111&view=rev
Log:
added switch to disable compression

Modified:
    incubator/click/trunk/click/extras/src/org/apache/click/extras/filter/PerformanceFilter.java

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/filter/PerformanceFilter.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/filter/PerformanceFilter.java?rev=832111&r1=832110&r2=832111&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/filter/PerformanceFilter.java
(original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/filter/PerformanceFilter.java
Mon Nov  2 21:26:08 2009
@@ -124,6 +124,9 @@
  * through the <tt>init-param</tt> <span class="blue">"compression-threshold"</span>.
  * <p/>
  * Click *.htm pages are automatically compressed by the filter.
+ * <p/>
+ * It is also possible to disable GZIP compression by setting the
+ * <tt>init-param</tt> <span class="blue">"compression-enabled"</span>
to false.
  *
  * <h3>Page Template Import References</h3>
  *
@@ -275,6 +278,9 @@
     /** The threshold number to compress, default value is 384 bytes. */
     protected int compressionThreshold = MIN_COMPRESSION_THRESHOLD;
 
+    /** Indicates if compression is enabled or not, default value is true. */
+    protected boolean compressionEnabled = true;
+
     /** The fitler has been configured flag. */
     protected boolean configured;
 
@@ -457,8 +463,14 @@
         ServletContext servletContext = getFilterConfig().getServletContext();
         configService = ClickUtils.getConfigService(servletContext);
 
+        // Get gzip enabled parameter
+        String param = filterConfig.getInitParameter("compression-enabled");
+        if (StringUtils.isNotBlank(param)) {
+            compressionEnabled = Boolean.parseBoolean(param);
+        }
+
         // Get compression threshold
-        String param = filterConfig.getInitParameter("compression-threshold");
+        param = filterConfig.getInitParameter("compression-threshold");
         if (param != null) {
             compressionThreshold = Integer.parseInt(param);
             if (compressionThreshold != 0
@@ -694,6 +706,10 @@
     protected boolean useGzipCompression(HttpServletRequest request,
         HttpServletResponse response, String path) {
 
+        if (!compressionEnabled) {
+            return false;
+        }
+
         // If Content-Encoding header is already set on response, skip compression
         if (response.containsHeader("Content-Encoding")) {
             return false;



Mime
View raw message