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/02/26 22:33:53 UTC

trafficserver git commit: Header-rewrite update

Repository: trafficserver
Updated Branches:
  refs/heads/master 115eabd1e -> c61e7d2a3


Header-rewrite update

Add support for URL and SCHEME set-destination qualifiers


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

Branch: refs/heads/master
Commit: c61e7d2a3c6796543dfabcd5b9ea47f193d2ca8f
Parents: 115eabd
Author: Thomas Jackson <ja...@apache.org>
Authored: Thu Feb 26 13:31:36 2015 -0800
Committer: Thomas Jackson <ja...@apache.org>
Committed: Thu Feb 26 13:33:42 2015 -0800

----------------------------------------------------------------------
 doc/reference/plugins/header_rewrite.en.rst |  6 ++++--
 plugins/header_rewrite/operators.cc         | 24 +++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c61e7d2a/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 6a7e47c..f17a1a1 100644
--- a/doc/reference/plugins/header_rewrite.en.rst
+++ b/doc/reference/plugins/header_rewrite.en.rst
@@ -10,9 +10,9 @@ Header Rewrite Plugin
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
- 
+
    http://www.apache.org/licenses/LICENSE-2.0
- 
+
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -76,6 +76,8 @@ Where qual is one of the support URL qualifiers::
   PORT
   PATH
   QUERY
+  SCHEME
+  URL
 
 For example (as a remap rule)::
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c61e7d2a/plugins/header_rewrite/operators.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/operators.cc b/plugins/header_rewrite/operators.cc
index 22aceee..c1484a8 100644
--- a/plugins/header_rewrite/operators.cc
+++ b/plugins/header_rewrite/operators.cc
@@ -234,9 +234,31 @@ OperatorSetDestination::exec(const Resources& res) const
       }
       break;
     case URL_QUAL_URL:
-      // TODO: Implement URL parser.
+      if (_value.empty()){
+        TSDebug(PLUGIN_NAME, "Would set destination URL to an empty value, skipping");
+      } else {
+        const char *start = _value.get_value().c_str();
+        const char *end = _value.get_value().size() + start;
+        TSMLoc new_url_loc;
+        if (TSUrlCreate(bufp, &new_url_loc) == TS_SUCCESS &&
+            TSUrlParse(bufp, new_url_loc, &start, end) == TS_PARSE_DONE &&
+            TSHttpHdrUrlSet(bufp, res.hdr_loc, new_url_loc) == TS_SUCCESS){
+          TSDebug(PLUGIN_NAME, "Set destination URL to %s", _value.get_value().c_str());
+        } else {
+          TSDebug(PLUGIN_NAME, "Failed to set URL %s", _value.get_value().c_str());
+        }
+      }
+      break;
+    case URL_QUAL_SCHEME:
+      if (_value.empty()){
+        TSDebug(PLUGIN_NAME, "Would set destination SCHEME to an empty value, skipping");
+      } else {
+        TSUrlSchemeSet(bufp, url_m_loc, _value.get_value().c_str(), _value.get_value().length());
+        TSDebug(PLUGIN_NAME, "OperatorSetDestination::exec() invoked with SCHEME: %s", _value.get_value().c_str());
+      }
       break;
     default:
+      TSDebug(PLUGIN_NAME, "Set destination %i has no handler", _url_qual);
       break;
     }
   } else {