trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject git commit: TS-2008: Cache control with multiple suffixes.
Date Thu, 31 Oct 2013 16:42:55 GMT
Updated Branches:
  refs/heads/master d1006996b -> 84634608b


TS-2008: Cache control with multiple suffixes.


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

Branch: refs/heads/master
Commit: 84634608b3c4cb87cc7b94ca81d57000c3191ef5
Parents: d100699
Author: bettydramit <b13621367396@gmail.com>
Authored: Fri Nov 1 00:41:06 2013 +0800
Committer: Zhao Yongming <ming.zym@gmail.com>
Committed: Fri Nov 1 00:42:15 2013 +0800

----------------------------------------------------------------------
 CHANGES              |  3 +++
 proxy/ControlBase.cc | 44 ++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 43 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/84634608/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 18a67f1..9295d01 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 Changes with Apache Traffic Server 4.1.0
 
 
+  *) [TS-2208] Cache control with multiple suffixes.
+    Author: bettydramit <b13621367396@gmail.com>
+
   *) [TS-2247] ua close time in milestone may not set.
    Author: Gang Li
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/84634608/proxy/ControlBase.cc
----------------------------------------------------------------------
diff --git a/proxy/ControlBase.cc b/proxy/ControlBase.cc
index 0a1953e..3335616 100644
--- a/proxy/ControlBase.cc
+++ b/proxy/ControlBase.cc
@@ -364,6 +364,38 @@ void TextMod::set(const char * value) {
   this->text.set(ats_strdup(value), strlen(value));
 }
 
+struct MultiTextMod : public ControlBase::Modifier {
+  Vec<ts::Buffer> text_vec;
+  MultiTextMod();
+  ~MultiTextMod();
+
+  // Copy the value to the MultiTextMod buffer.
+  void set(char * value);
+
+  // Calls name() which the subclass must provide.
+  virtual void print(FILE* f) const;
+};
+
+MultiTextMod::MultiTextMod() {}
+MultiTextMod::~MultiTextMod() {
+  text_vec.clear();
+}
+
+void MultiTextMod::print(FILE* f) const {
+  for_Vec(ts::Buffer, text_iter, this->text_vec)
+    fprintf(f, "%s=%*s ", this->name(),static_cast<int>(text_iter.size()),text_iter.data());
+}
+
+void MultiTextMod::set(char * value) {
+  Tokenizer rangeTok(",");
+  int num_tok = rangeTok.Initialize(value, SHARE_TOKS);
+  for(int i = 0; i < num_tok; i++){
+    ts::Buffer text(0);
+    text.set(ats_strdup(rangeTok[i]), strlen(rangeTok[i]));
+    this->text_vec.push_back(text);
+  }
+}
+
 // ----------
 struct MethodMod : public TextMod {
   static char const * const NAME;
@@ -429,7 +461,7 @@ PrefixMod::make(char * value, char const ** /* error ATS_UNUSED */) {
 }
 
 // ----------
-struct SuffixMod : public TextMod {
+struct SuffixMod : public MultiTextMod {
   static char const * const NAME;
 
   virtual Type type() const;
@@ -443,9 +475,13 @@ char const * SuffixMod::name() const { return NAME; }
 bool SuffixMod::check(HttpRequestData* req) const {
   int path_len;
   char const* path = req->hdr->url_get()->path_get(&path_len);
-  return path_len >= static_cast<int>(text.size())
-    && 0 == strncasecmp(path + path_len - text.size(), text.data(), text.size())
-    ;
+  if(1 == static_cast<int>(this->text_vec.count()) && 1 == static_cast<int>(this->text_vec[0].size())
&& 0 == strcmp(this->text_vec[0].data(),"*"))
+    return true;
+  for_Vec(ts::Buffer, text_iter, this->text_vec){
+    if (path_len >= static_cast<int>(text_iter.size()) && 0 == strncasecmp(path
+ path_len - text_iter.size(), text_iter.data(), text_iter.size()))
+      return true;
+  }
+  return false;
 }
 SuffixMod*
 SuffixMod::make(char * value, char const ** /* error ATS_UNUSED */) {


Mime
View raw message