You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by rr...@apache.org on 2019/07/16 16:42:33 UTC

[trafficserver] branch master updated: Remove header_rewrite conditions deprecated in previous versions

This is an automated email from the ASF dual-hosted git repository.

rrm 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 37ae0d3  Remove header_rewrite conditions deprecated in previous versions
37ae0d3 is described below

commit 37ae0d34b2ad6a44e42c3fe88925f0f98682ba0c
Author: Randall Meyer <rr...@apache.org>
AuthorDate: Mon Jul 15 17:09:59 2019 -0700

    Remove header_rewrite conditions deprecated in previous versions
---
 doc/admin-guide/plugins/header_rewrite.en.rst |  50 +-----------
 plugins/header_rewrite/conditions.cc          | 108 --------------------------
 plugins/header_rewrite/conditions.h           |  56 -------------
 plugins/header_rewrite/factory.cc             |   6 --
 plugins/header_rewrite/header_rewrite_test.cc |  12 +--
 5 files changed, 7 insertions(+), 225 deletions(-)

diff --git a/doc/admin-guide/plugins/header_rewrite.en.rst b/doc/admin-guide/plugins/header_rewrite.en.rst
index 05267b5..e5951e7 100644
--- a/doc/admin-guide/plugins/header_rewrite.en.rst
+++ b/doc/admin-guide/plugins/header_rewrite.en.rst
@@ -323,7 +323,7 @@ This condition provides access to information about the inbound (client, user ag
 The data that can be checked is ::
 
    %{INBOUND:LOCAL-ADDR}      The local (ATS) address for the connection. Equivalent to %{IP:INBOUND}.
-   %{INBOUND:LOCAL-PORT}      The local (ATS) port for the connection. Equivalent to %{INCOMING-PORT}.
+   %{INBOUND:LOCAL-PORT}      The local (ATS) port for the connection.
    %{INBOUND:REMOTE-ADDR}     The client address for the connection. Equivalent to %{IP:CLIENT}.
    %{INBOUND:REMOTE-PORT}     The client port for the connection.
    %{INBOUND:TLS}             The TLS protocol if the connection is over TLS, otherwise the empty string.
@@ -351,17 +351,6 @@ which is true when the connection is not TLS. The arguments ``H2``, ``IPV4``, an
 same way.
 
 
-INCOMING-PORT
-~~~~~~~~~~~~~
-::
-
-    cond %{INCOMING-PORT} <operand>
-
-TCP port, as a decimal integer, on which the incoming client connection was
-made.
-
-This condition is *deprecated* as of ATS v8.0.x, please use ``%{INBOUND:LOCAL-PORT}`` instead.
-
 IP
 ~~
 ::
@@ -387,8 +376,6 @@ actually as a value to an operator, e.g. ::
      set-header X-Server-IP %{IP:SERVER}
      set-header X-Outbound-IP %{IP:OUTBOUND}
 
-Finally, this new condition replaces the old %{CLIENT-IP} condition, which is
-now properly deprecated. It will be removed as of ATS v8.0.0.
 
 INTERNAL-TRANSACTION
 ~~~~~~~~~~~~~~~~~~~~
@@ -430,37 +417,6 @@ values, such as year, month etc.
     %{NOW:WEEKDAY}   Current weekday (0-6, 0 == Sunday)
     %{NOW:YEARDAY}   Current day of the year (0-365, 0 == Jan 1st)
 
-PATH
-~~~~
-::
-
-    cond %{PATH} <operand>
-
-The path component of the transaction. This does NOT include the leading ``/`` that
-immediately follows the hostname and terminates prior to the ``?`` signifying
-the beginning of query parameters (or the end of the URL, whichever occurs
-first).
-
-Refer to `Requests vs. Responses`_ for more information on determining the
-context in which the transaction's URL is evaluated.
-
-This condition is *deprecated* as of ATS v7.1.x, please use e.g. %{URL:PATH}
-or %{CLIENT-URL:PATH} instead.
-
-
-QUERY
-~~~~~
-::
-
-    cond %{QUERY} <operand>
-
-The query parameters, if any, of the transaction.  Refer to `Requests vs.
-Responses`_ for more information on determining the context in which the
-transaction's URL is evaluated.
-
-This condition is *deprecated* as of ATS v7.1.x, please use e.g. %{URL:QUERY}
-or %{CLIENT-URL:QUERY} instead.
-
 
 RANDOM
 ~~~~~~
@@ -998,10 +954,6 @@ evaluated and will adjust using request or response entities automatically:
 
 - `METHOD`_
 
-- `PATH`_
-
-- `QUERY`_
-
 - `URL`_
 
 Affected Operators
diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc
index 92cac5d..380d270 100644
--- a/plugins/header_rewrite/conditions.cc
+++ b/plugins/header_rewrite/conditions.cc
@@ -248,83 +248,6 @@ ConditionHeader::eval(const Resources &res)
   return static_cast<const MatcherType *>(_matcher)->test(s);
 }
 
-// ConditionPath
-void
-ConditionPath::initialize(Parser &p)
-{
-  Condition::initialize(p);
-  MatcherType *match = new MatcherType(_cond_op);
-
-  match->set(p.get_arg());
-  _matcher = match;
-}
-
-void
-ConditionPath::append_value(std::string &s, const Resources &res)
-{
-  TSMBuffer bufp;
-  TSMLoc url_loc;
-
-  if (TSHttpTxnPristineUrlGet(res.txnp, &bufp, &url_loc) == TS_SUCCESS) {
-    int path_length;
-    const char *path = TSUrlPathGet(bufp, url_loc, &path_length);
-
-    if (path && path_length) {
-      s.append(path, path_length);
-    }
-
-    TSHandleMLocRelease(bufp, TS_NULL_MLOC, url_loc);
-  }
-}
-
-bool
-ConditionPath::eval(const Resources &res)
-{
-  std::string s;
-
-  append_value(s, res);
-  TSDebug(PLUGIN_NAME, "Evaluating PATH()");
-
-  return static_cast<MatcherType *>(_matcher)->test(s);
-}
-
-// ConditionQuery
-void
-ConditionQuery::initialize(Parser &p)
-{
-  Condition::initialize(p);
-  MatcherType *match = new MatcherType(_cond_op);
-
-  match->set(p.get_arg());
-  _matcher = match;
-}
-
-void
-ConditionQuery::append_value(std::string &s, const Resources &res)
-{
-  int query_len     = 0;
-  const char *query = TSUrlHttpQueryGet(res._rri->requestBufp, res._rri->requestUrl, &query_len);
-
-  TSDebug(PLUGIN_NAME, "Appending QUERY to evaluation value: %.*s", query_len, query);
-  s.append(query, query_len);
-}
-
-bool
-ConditionQuery::eval(const Resources &res)
-{
-  if (nullptr != res._rri) {
-    std::string s;
-
-    append_value(s, res);
-    TSDebug(PLUGIN_NAME, "Evaluating QUERY()");
-
-    return static_cast<const MatcherType *>(_matcher)->test(s);
-  }
-
-  TSDebug(PLUGIN_NAME, "\tQUERY requires remap initialization! Evaluating to false!");
-  return false;
-}
-
 // ConditionUrl: request or response header. TODO: This is not finished, at all!!!
 void
 ConditionUrl::initialize(Parser &p)
@@ -652,37 +575,6 @@ ConditionIp::append_value(std::string &s, const Resources &res)
   }
 }
 
-void
-ConditionIncomingPort::initialize(Parser &p)
-{
-  Condition::initialize(p);
-
-  MatcherType *match = new MatcherType(_cond_op);
-
-  match->set(static_cast<uint16_t>(strtoul(p.get_arg().c_str(), nullptr, 10)));
-  _matcher = match;
-}
-
-bool
-ConditionIncomingPort::eval(const Resources &res)
-{
-  uint16_t port = getPort(TSHttpTxnIncomingAddrGet(res.txnp));
-
-  TSDebug(PLUGIN_NAME, "Evaluating INCOMING-PORT()");
-  return static_cast<MatcherType *>(_matcher)->test(port);
-}
-
-void
-ConditionIncomingPort::append_value(std::string &s, const Resources &res)
-{
-  std::ostringstream oss;
-  uint16_t port = getPort(TSHttpTxnIncomingAddrGet(res.txnp));
-
-  oss << port;
-  s += oss.str();
-  TSDebug(PLUGIN_NAME, "Appending %d to evaluation value -> %s", port, s.c_str());
-}
-
 // ConditionTransactCount
 void
 ConditionTransactCount::initialize(Parser &p)
diff --git a/plugins/header_rewrite/conditions.h b/plugins/header_rewrite/conditions.h
index 77ef595..927c823 100644
--- a/plugins/header_rewrite/conditions.h
+++ b/plugins/header_rewrite/conditions.h
@@ -266,44 +266,6 @@ private:
   bool _client;
 };
 
-// path
-class ConditionPath : public Condition
-{
-  typedef Matchers<std::string> MatcherType;
-
-public:
-  explicit ConditionPath() { TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionPath"); }
-
-  // noncopyable
-  ConditionPath(const ConditionPath &) = delete;
-  void operator=(const ConditionPath &) = delete;
-
-  void initialize(Parser &p) override;
-  void append_value(std::string &s, const Resources &res) override;
-
-protected:
-  bool eval(const Resources &res) override;
-};
-
-// query
-class ConditionQuery : public Condition
-{
-  typedef Matchers<std::string> MatcherType;
-
-public:
-  explicit ConditionQuery() { TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionQuery"); }
-
-  // noncopyable
-  ConditionQuery(const ConditionQuery &) = delete;
-  void operator=(const ConditionQuery &) = delete;
-
-  void initialize(Parser &p) override;
-  void append_value(std::string &s, const Resources &res) override;
-
-protected:
-  bool eval(const Resources &res) override;
-};
-
 // url
 class ConditionUrl : public Condition
 {
@@ -405,24 +367,6 @@ private:
   IpQualifiers _ip_qual = IP_QUAL_CLIENT;
 };
 
-class ConditionIncomingPort : public Condition
-{
-  typedef Matchers<uint16_t> MatcherType;
-
-public:
-  ConditionIncomingPort() { TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionIncomingPort"); }
-
-  // noncopyable
-  ConditionIncomingPort(const ConditionIncomingPort &) = delete;
-  void operator=(const ConditionIncomingPort &) = delete;
-
-  void initialize(Parser &p) override;
-  void append_value(std::string &s, const Resources &res) override;
-
-protected:
-  bool eval(const Resources &res) override;
-};
-
 // Transact Count
 class ConditionTransactCount : public Condition
 {
diff --git a/plugins/header_rewrite/factory.cc b/plugins/header_rewrite/factory.cc
index 028fc62..0d314e4 100644
--- a/plugins/header_rewrite/factory.cc
+++ b/plugins/header_rewrite/factory.cc
@@ -105,12 +105,8 @@ condition_factory(const std::string &cond)
     c = new ConditionCookie();
   } else if (c_name == "HEADER") { // This condition adapts to the hook
     c = new ConditionHeader();
-  } else if (c_name == "PATH") {
-    c = new ConditionPath();
   } else if (c_name == "CLIENT-HEADER") {
     c = new ConditionHeader(true);
-  } else if (c_name == "QUERY") {
-    c = new ConditionQuery();
   } else if (c_name == "CLIENT-URL") { // This condition adapts to the hook
     c = new ConditionUrl(ConditionUrl::CLIENT);
   } else if (c_name == "URL") {
@@ -127,8 +123,6 @@ condition_factory(const std::string &cond)
     c = new ConditionInternalTxn();
   } else if (c_name == "IP") {
     c = new ConditionIp();
-  } else if (c_name == "INCOMING-PORT") {
-    c = new ConditionIncomingPort();
   } else if (c_name == "METHOD") {
     c = new ConditionMethod();
   } else if (c_name == "TXN-COUNT") {
diff --git a/plugins/header_rewrite/header_rewrite_test.cc b/plugins/header_rewrite/header_rewrite_test.cc
index 4237059..cd032f2 100644
--- a/plugins/header_rewrite/header_rewrite_test.cc
+++ b/plugins/header_rewrite/header_rewrite_test.cc
@@ -224,11 +224,11 @@ test_parsing()
   }
 
   {
-    ParserTest p(R"(cond %{PATH} /\/foo\/bar/ [OR])");
+    ParserTest p(R"(cond %{CLIENT-URL:PATH} /\/foo\/bar/ [OR])");
 
     CHECK_EQ(p.getTokens().size(), 4UL);
     CHECK_EQ(p.getTokens()[0], "cond");
-    CHECK_EQ(p.getTokens()[1], "%{PATH}");
+    CHECK_EQ(p.getTokens()[1], "%{CLIENT-URL:PATH}");
     CHECK_EQ(p.getTokens()[2], R"(/\/foo\/bar/)");
     CHECK_EQ(p.getTokens()[3], "[OR]");
 
@@ -422,10 +422,10 @@ test_processing()
   }
 
   {
-    ParserTest p(R"(cond %{PATH} /\.html|\.txt/)");
+    ParserTest p(R"(cond %{CLIENT-URL:PATH} /\.html|\.txt/)");
 
     CHECK_EQ(p.getTokens().size(), 3UL);
-    CHECK_EQ(p.get_op(), "PATH");
+    CHECK_EQ(p.get_op(), "CLIENT-URL:PATH");
     CHECK_EQ(p.get_arg(), R"(/\.html|\.txt/)");
     CHECK_EQ(p.is_cond(), true);
 
@@ -433,10 +433,10 @@ test_processing()
   }
 
   {
-    ParserTest p(R"(cond %{PATH} /\/foo\/bar/)");
+    ParserTest p(R"(cond %{CLIENT-URL:PATH} /\/foo\/bar/)");
 
     CHECK_EQ(p.getTokens().size(), 3UL);
-    CHECK_EQ(p.get_op(), "PATH");
+    CHECK_EQ(p.get_op(), "CLIENT-URL:PATH");
     CHECK_EQ(p.get_arg(), R"(/\/foo\/bar/)");
     CHECK_EQ(p.is_cond(), true);