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 <[email protected]>
Authored: Fri Aug 28 14:27:25 2015 -0700
Committer: Thomas Jackson <[email protected]>
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;
     }
   }
 }

Reply via email to