You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ja...@apache.org on 2015/08/29 02:01:44 UTC

[1/2] trafficserver git commit: TS-3874: Header-rewrite: support multiple header values in conditionals

Repository: trafficserver
Updated Branches:
  refs/heads/master def621ef9 -> fd99ef716


TS-3874: Header-rewrite: support multiple header values in conditionals


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

Branch: refs/heads/master
Commit: 5cdbf4554f5bcff4d41765d90ff4616d50b8159a
Parents: def621e
Author: Thomas Jackson <ja...@apache.org>
Authored: Fri Aug 28 14:27:25 2015 -0700
Committer: Thomas Jackson <ja...@apache.org>
Committed: Fri Aug 28 16:42:50 2015 -0700

----------------------------------------------------------------------
 plugins/header_rewrite/conditions.cc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5cdbf455/plugins/header_rewrite/conditions.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc
index 696e1da..0336158 100644
--- a/plugins/header_rewrite/conditions.cc
+++ b/plugins/header_rewrite/conditions.cc
@@ -224,7 +224,6 @@ ConditionHeader::append_value(std::string &s, const Resources &res)
 {
   TSMBuffer bufp;
   TSMLoc hdr_loc;
-  TSMLoc field_loc;
   const char *value;
   int len;
 
@@ -237,13 +236,22 @@ ConditionHeader::append_value(std::string &s, const Resources &res)
   }
 
   if (bufp && hdr_loc) {
+    TSMLoc field_loc, next_field_loc;
+
     field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, _qualifier.c_str(), _qualifier.size());
     TSDebug(PLUGIN_NAME, "Getting Header: %s, field_loc: %p", _qualifier.c_str(), field_loc);
-    if (field_loc != NULL) {
+
+    while (field_loc) {
       value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &len);
+      next_field_loc = TSMimeHdrFieldNextDup(bufp, hdr_loc, field_loc);
       TSDebug(PLUGIN_NAME, "Appending HEADER(%s) to evaluation value -> %.*s", _qualifier.c_str(), len, value);
       s.append(value, len);
+      // multiple headers with the same name must be symantically the same as one value which is comma seperated (http://tools.ietf.org/html/rfc2616#section-4.2)
+      if (next_field_loc){
+        s.append(",");
+      }
       TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+      field_loc = next_field_loc;
     }
   }
 }


[2/2] trafficserver git commit: TS-3874 Add documentation for header conditionals in header-rewrite

Posted by ja...@apache.org.
TS-3874 Add documentation for header conditionals in header-rewrite


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

Branch: refs/heads/master
Commit: fd99ef7160f9e6620f6da979ea8cbd780ffbecf4
Parents: 5cdbf45
Author: Thomas Jackson <ja...@apache.org>
Authored: Fri Aug 28 15:53:16 2015 -0700
Committer: Thomas Jackson <ja...@apache.org>
Committed: Fri Aug 28 16:43:11 2015 -0700

----------------------------------------------------------------------
 doc/reference/plugins/header_rewrite.en.rst | 38 +++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fd99ef71/doc/reference/plugins/header_rewrite.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/header_rewrite.en.rst b/doc/reference/plugins/header_rewrite.en.rst
index 84c2e13..1af5f12 100644
--- a/doc/reference/plugins/header_rewrite.en.rst
+++ b/doc/reference/plugins/header_rewrite.en.rst
@@ -159,7 +159,7 @@ is required to match that section of the URL.
 
 Supported Option Names:
    HOST
-   
+
 Example:
    cond %{URL:HOST} =www.example.com
 
@@ -208,3 +208,39 @@ Examples
   rm-header Set-Cookie
   counter plugin.header_rewrite.x-y-foobar-dc1
   cond %{HEADER:X-Y-Foobar} "Some string" [AND,NC]
+
+
+.. note:: Notes about header conditionals
+
+  In HTTP multple headers can be consolidated into a single comma separated string.
+  To avoid complex markup within header-rewrite all header conditionals are
+  evaluated against all values of the header normalized into a single comma separated string.
+  Some examples:
+
+  Conditions
+  ::
+     # rule 1
+    cond %{HEADER:foo} /bar/
+
+     # rule 2
+    cond %{HEADER:foo} =bar
+
+  Examples
+  ::
+
+    # matches 1 and 2
+    foo: bar
+
+    # matches 1
+    foo: bar
+    foo: baz
+
+    # matches 1
+    foo: baz
+    foo: bar
+
+    # matches 1
+    foo: bar,baz
+
+    # matches 1
+    foo: baz,bar