You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by su...@apache.org on 2015/02/20 17:15:36 UTC
[1/2] trafficserver git commit: [TS-3398]: Enhance header_rewrite to
support METHOD as a condition
Repository: trafficserver
Updated Branches:
refs/heads/master 2f0440f10 -> e54dd3a3a
[TS-3398]: Enhance header_rewrite to support METHOD as a condition
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/c7943921
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/c7943921
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/c7943921
Branch: refs/heads/master
Commit: c79439212794f2d2df1db20b2278ac1fb96b1558
Parents: 2f0440f
Author: Sudheer Vinukonda <su...@yahoo-inc.com>
Authored: Fri Feb 20 16:14:15 2015 +0000
Committer: Sudheer Vinukonda <su...@yahoo-inc.com>
Committed: Fri Feb 20 16:14:15 2015 +0000
----------------------------------------------------------------------
plugins/header_rewrite/conditions.cc | 43 +++++++++++++++++++++++++++++++
plugins/header_rewrite/conditions.h | 19 ++++++++++++++
plugins/header_rewrite/factory.cc | 2 ++
3 files changed, 64 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c7943921/plugins/header_rewrite/conditions.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc
index be3d28b..04fb456 100644
--- a/plugins/header_rewrite/conditions.cc
+++ b/plugins/header_rewrite/conditions.cc
@@ -72,6 +72,49 @@ ConditionStatus::append_value(std::string& s, const Resources& res)
}
+// ConditionMethod
+void
+ConditionMethod::initialize(Parser& p)
+{
+ Condition::initialize(p);
+
+ Matchers<std::string>* match = new Matchers<std::string>(_cond_op);
+ match->set(p.get_arg());
+
+ _matcher = match;
+}
+
+bool
+ConditionMethod::eval(const Resources& res)
+{
+ std::string s;
+
+ append_value(s, res);
+ bool rval = static_cast<const Matchers<std::string>*>(_matcher)->test(s);
+ TSDebug(PLUGIN_NAME, "Evaluating METHOD(): %s - rval: %d", s.c_str(), rval);
+ return rval;
+}
+
+
+void
+ConditionMethod::append_value(std::string& s, const Resources& res)
+{
+ TSMBuffer bufp;
+ TSMLoc hdr_loc;
+ const char* value;
+ int len;
+
+ bufp = res.client_bufp;
+ hdr_loc = res.client_hdr_loc;
+
+ if (bufp && hdr_loc) {
+ value = TSHttpHdrMethodGet(bufp, hdr_loc, &len);
+ TSDebug(PLUGIN_NAME, "Appending METHOD(%s) to evaluation value -> %.*s", _qualifier.c_str(), len, value);
+ s.append(value, len);
+ }
+}
+
+
// ConditionRandom: random 0 to (N-1)
void
ConditionRandom::initialize(Parser& p)
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c7943921/plugins/header_rewrite/conditions.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/conditions.h b/plugins/header_rewrite/conditions.h
index fbb843d..f540df1 100644
--- a/plugins/header_rewrite/conditions.h
+++ b/plugins/header_rewrite/conditions.h
@@ -101,6 +101,25 @@ private:
};
+// Check the HTTP method
+class ConditionMethod : public Condition
+{
+public:
+ ConditionMethod()
+ {
+ TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionMethod");
+ }
+ void initialize(Parser& p);
+ void append_value(std::string& s, const Resources& res);
+
+protected:
+ bool eval(const Resources& res);
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(ConditionMethod);
+};
+
+
// Random 0 to (N-1)
class ConditionRandom : public Condition
{
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c7943921/plugins/header_rewrite/factory.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/factory.cc b/plugins/header_rewrite/factory.cc
index eb44369..eeff0aa 100644
--- a/plugins/header_rewrite/factory.cc
+++ b/plugins/header_rewrite/factory.cc
@@ -115,6 +115,8 @@ condition_factory(const std::string& cond)
c = new ConditionClientIp();
} else if (c_name == "INCOMING-PORT") {
c = new ConditionIncomingPort();
+ } else if (c_name == "METHOD") {
+ c = new ConditionMethod();
} else {
TSError("%s: unknown condition: %s", PLUGIN_NAME, c_name.c_str());
return NULL;
[2/2] trafficserver git commit: update CHANGES
Posted by su...@apache.org.
update CHANGES
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e54dd3a3
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e54dd3a3
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e54dd3a3
Branch: refs/heads/master
Commit: e54dd3a3afe69a412334cd5d05cd9747b5e1136e
Parents: c794392
Author: Sudheer Vinukonda <su...@yahoo-inc.com>
Authored: Fri Feb 20 16:15:10 2015 +0000
Committer: Sudheer Vinukonda <su...@yahoo-inc.com>
Committed: Fri Feb 20 16:15:10 2015 +0000
----------------------------------------------------------------------
CHANGES | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e54dd3a3/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index f1dfe7d..704e0c0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 5.3.0
+ *) [TS-3398] Enhance header_rewrite to support METHOD as a condition
+
*) [TS-3394] Return an error on a non-http response
*) [TS-3390] TrafficServer segfaults on shutdown because of uninitialized SPDY sessions