You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2015/09/08 18:24:33 UTC

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

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

(cherry picked from commit 5cdbf4554f5bcff4d41765d90ff4616d50b8159a)


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

Branch: refs/heads/6.0.x
Commit: 0b854030fe760c91e4ed72a78aa245833315d417
Parents: 82dbacf
Author: Thomas Jackson <ja...@apache.org>
Authored: Fri Aug 28 14:27:25 2015 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Tue Sep 8 09:19:16 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/0b854030/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;
     }
   }
 }