You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by os...@apache.org on 2013/01/17 08:12:45 UTC

git commit: TS-1659 Gzip: Make it possible to "remove" compressible-content-type

Updated Branches:
  refs/heads/master 74f1175cb -> 594c41ac1


TS-1659 Gzip: Make it possible to "remove" compressible-content-type

this should implement compressible_content_type !expression
however, I have not been able to test it yet, as trafficserver won't
compile on my machine


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/594c41ac
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/594c41ac
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/594c41ac

Branch: refs/heads/master
Commit: 594c41ac1eb128c5757e2d95db9241243b8d2520
Parents: 74f1175
Author: Otto van der Schaaf <os...@gmail.com>
Authored: Thu Jan 17 08:11:02 2013 +0100
Committer: Otto van der Schaaf <os...@gmail.com>
Committed: Thu Jan 17 08:11:02 2013 +0100

----------------------------------------------------------------------
 plugins/experimental/gzip/README             |    3 +++
 plugins/experimental/gzip/configuration.cc   |   16 +++++++++++-----
 plugins/experimental/gzip/sample.gzip.config |    2 ++
 3 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/594c41ac/plugins/experimental/gzip/README
----------------------------------------------------------------------
diff --git a/plugins/experimental/gzip/README b/plugins/experimental/gzip/README
index 94962ff..be357c1 100644
--- a/plugins/experimental/gzip/README
+++ b/plugins/experimental/gzip/README
@@ -53,6 +53,9 @@ cache false
 
 compressible-content-type text/*
 compressible-content-type *javascript*
+#disabling is possible too
+compressible-content-type !text/javascript
+
 disallow /notthis/*.js
 disallow /notthat*
 disallow */bla*

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/594c41ac/plugins/experimental/gzip/configuration.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/gzip/configuration.cc b/plugins/experimental/gzip/configuration.cc
index 3480791..693de50 100644
--- a/plugins/experimental/gzip/configuration.cc
+++ b/plugins/experimental/gzip/configuration.cc
@@ -128,17 +128,23 @@ namespace Gzip {
   }
 
   bool HostConfiguration::ContentTypeIsCompressible(const char * content_type, int content_type_length) {
-   string scontent_type(content_type, content_type_length);
-
+    string scontent_type(content_type, content_type_length);
+    bool is_match = false;
+    
     for (size_t i = 0; i < compressible_content_types_.size(); i++) {
-      if ( fnmatch (compressible_content_types_[i].c_str(), scontent_type.c_str(), 0) == 0 ) {
+      const char* match_string = compressible_content_types_[i].c_str();
+      bool exclude = match_string[0] == '!';
+      if (exclude) {
+        match_string++;//skip '!'
+      }
+      if ( fnmatch (match_string, scontent_type.c_str(), 0) == 0 ) {
         info("compressible content type [%s], matched on pattern [%s]",
             scontent_type.c_str(), compressible_content_types_[i].c_str());
-        return true;
+        is_match = !exclude;
       }
     }
 
-    return false;
+    return is_match;
   }
 
   Configuration * Configuration::Parse(const char * path ) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/594c41ac/plugins/experimental/gzip/sample.gzip.config
----------------------------------------------------------------------
diff --git a/plugins/experimental/gzip/sample.gzip.config b/plugins/experimental/gzip/sample.gzip.config
index e763aa6..2dd34ae 100644
--- a/plugins/experimental/gzip/sample.gzip.config
+++ b/plugins/experimental/gzip/sample.gzip.config
@@ -49,6 +49,8 @@ disallow */bla*
 enabled true
 remove-accept-encoding true
 compressible-content-type text/*
+#disable a content type
+compressible-content-type !text/javascript
 
 cache false
 disallow /notthis/*.js