trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject [trafficserver] branch master updated: Makes the default set of status codes removable via configs
Date Fri, 30 Mar 2018 18:38:30 GMT
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 1b1b174  Makes the default set of status codes removable via configs
1b1b174 is described below

commit 1b1b174fdbc547bd5667ed0e3ffafea8ca91854d
Author: Leif Hedstrom <zwoop@apache.org>
AuthorDate: Fri Mar 30 08:06:09 2018 -0600

    Makes the default set of status codes removable via configs
---
 plugins/gzip/configuration.cc | 18 +++++++++++++++++-
 plugins/gzip/configuration.h  |  1 +
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/plugins/gzip/configuration.cc b/plugins/gzip/configuration.cc
index 155b5de..109ddfa 100644
--- a/plugins/gzip/configuration.cc
+++ b/plugins/gzip/configuration.cc
@@ -115,6 +115,15 @@ Configuration::add_host_configuration(HostConfiguration *hc)
 }
 
 void
+HostConfiguration::update_defaults()
+{
+  // maintain backwards compatibility/usability out of the box
+  if (compressible_status_codes_.empty()) {
+    compressible_status_codes_ = {TS_HTTP_STATUS_OK, TS_HTTP_STATUS_PARTIAL_CONTENT, TS_HTTP_STATUS_NOT_MODIFIED};
+  }
+}
+
+void
 HostConfiguration::add_disallow(const std::string &disallow)
 {
   disallows_.push_back(disallow);
@@ -295,6 +304,7 @@ Configuration::Parse(const char *path)
 
   Configuration *c                              = new Configuration();
   HostConfiguration *current_host_configuration = new HostConfiguration("");
+
   c->add_host_configuration(current_host_configuration);
 
   if (pathstring.empty()) {
@@ -341,7 +351,10 @@ Configuration::Parse(const char *path)
       switch (state) {
       case kParseStart:
         if ((token[0] == '[') && (token[token.size() - 1] == ']')) {
-          std::string current_host   = token.substr(1, token.size() - 2);
+          std::string current_host = token.substr(1, token.size() - 2);
+
+          // Makes sure that any default settings are properly set, when not explicitly set
via configs
+          current_host_configuration->update_defaults();
           current_host_configuration = new HostConfiguration(current_host);
           c->add_host_configuration(current_host_configuration);
         } else if (token == "compressible-content-type") {
@@ -400,6 +413,9 @@ Configuration::Parse(const char *path)
     }
   }
 
+  // Update the defaults for the last host configuration too, if needed.
+  current_host_configuration->update_defaults();
+
   if (state != kParseStart) {
     warning("the parser state indicates that data was expected when it reached the end of
the file (%d)", state);
   }
diff --git a/plugins/gzip/configuration.h b/plugins/gzip/configuration.h
index d8c4166..0f671f4 100644
--- a/plugins/gzip/configuration.h
+++ b/plugins/gzip/configuration.h
@@ -112,6 +112,7 @@ public:
     return !allows_.empty();
   }
 
+  void update_defaults();
   void add_disallow(const std::string &disallow);
   void add_allow(const std::string &allow);
   void add_compressible_content_type(const std::string &content_type);

-- 
To stop receiving notification emails like this one, please contact
zwoop@apache.org.

Mime
View raw message