You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2013/09/23 21:52:27 UTC

[13/20] git commit: Update docs for the header_rewrite plugin

Update docs for the header_rewrite plugin


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

Branch: refs/heads/5.0.x
Commit: 4fab19a1ad865e231849e1417f32177b853f9332
Parents: f3fa606
Author: Leif Hedstrom <le...@ogre.com>
Authored: Fri Sep 13 17:38:29 2013 -0600
Committer: Leif Hedstrom <le...@ogre.com>
Committed: Fri Sep 13 17:38:29 2013 -0600

----------------------------------------------------------------------
 plugins/header_rewrite/README                | 88 +++++++++++++++------
 plugins/header_rewrite/header_rewrite.config | 94 -----------------------
 2 files changed, 66 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4fab19a1/plugins/header_rewrite/README
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/README b/plugins/header_rewrite/README
index df8165f..ed6eeb0 100644
--- a/plugins/header_rewrite/README
+++ b/plugins/header_rewrite/README
@@ -8,16 +8,16 @@ Note that currently only static string "values" are supported. We'll add
 advanced features to allow for expansions in a future release.
 
 
-Operations
-----------
+Operators
+---------
+The following operators are available: 
 
   rm-header header-name			[flags]
-  add-header header "string"		[flags]
-  set-status status-code		[flags]
-  set-status-reason reason-string	[flags]
+  add-header header <value>		[flags]
+  set-status <status-code>		[flags]
+  set-status-reason <value>		[flags]
   no-op		    			[flags]
 
-
 The following operator(s) currently only works when instantiating the
 plugin as a remap plugin:
 
@@ -36,24 +36,41 @@ For example (as a remap rule):
   set-destination HOST foo.mobile.bar.com [L]
 
 
-
-Operation flags
----------------
+Operator flags
+--------------
   [L]	Last rule, do not continue
 
 
 Conditions
 ----------
-
-  cond %{STATUS} operand	[flags]
-  cond %{RANDOM:nn} operand	[flags]
-  cond %{ACCESS:file}		[flags]
-  cond %{TRUE}			[flags]
-  cond %{FALSE}			[flags]
-  cond %{HEADER:header-name}	[flags]
-
-
-These conditions have to be first in a ruleset, and you can only have one:
+The conditions are used as qualifiers: The operators specified will
+only be evaluated if the condition(s) are met.
+
+  cond %{STATUS} operand			[flags]
+  cond %{RANDOM:nn} operand			[flags]
+  cond %{ACCESS:file}				[flags]
+  cond %{TRUE}					[flags]
+  cond %{FALSE}					[flags]
+  cond %{HEADER:header-name} operand		[flags]
+  cond %{CLIENT-HEADER:header-name} operand	[flags]
+  cond %{METHOD} operand			[flags]
+  cond %{PROTOCOL} operand			[flags]
+  cond %{PORT} operand				[flags]
+  cond %{HOST} operand				[flags]
+  cond %{TOHOST} operand			[false]
+  cond %{FROMHOST} operand			[false]
+  cond %{PATH} operand				[false]
+  cond %{PARAMS} operand			[false]
+  cond %{QUERY} operand				[false]
+
+
+The difference between HEADER and CLIENT-HEADER is that HEADER adapts to the
+hook it's running in, whereas CLIENT-HEADER always applies to the client
+request header. The %{TRUE} condition is also the default condition if no
+other conditions are specified.
+
+These conditions have to be first in a ruleset, and you can only have one in
+each rule. This implies that a new hook condition starts a new rule as well.
 
   cond %{READ_RESPONSE_HDR_HOOK}   (this is the default hook)
   cond %{READ_REQUEST_HDR_HOOK}
@@ -63,6 +80,7 @@ These conditions have to be first in a ruleset, and you can only have one:
 
 Condition flags
 ---------------
+  [NC]  Not ase sensitive condition (when applicable)
   [AND]	AND with next condition (default)
   [OR]	OR with next condition
   [NOT]	Invert this condition
@@ -70,9 +88,35 @@ Condition flags
 
 Operands to conditions
 ----------------------
-  =val	Lexically equal
-  <val	Lexically less then
-  >val	Lexically greater then   
+  /string/  # regular expression
+  <string   # lexically lower
+  >string   # lexically greater
+  =string   # lexically equal
+
+The absense of a "matcher" means value exists).
+
+
+Values
+------
+Setting e.g. a header with a value can take the following formats:
+
+  - Any of the cond definitions, that extracts a value from the request
+  - $N 0 <= N <= 9, as grouped in a regular expression
+  - string (which can contain the above)
+  - null
+
+
+Examples
+--------
+
+cond %{HEADER:X-Y-Foobar}
+cond %{METHOD} =GET [OR]
+cond %{METHOD} =POST
+set-header X-Y-Fiefum %{HEADER:X-Y-Foobar}
+rm-header X-Y-Foobar
+rm-header Set-Cookie
+
+cond %{HEADER:X-Y-Foobar} "Some string" [AND,NC]
 
 
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4fab19a1/plugins/header_rewrite/header_rewrite.config
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/header_rewrite.config b/plugins/header_rewrite/header_rewrite.config
deleted file mode 100644
index 2b83d1a..0000000
--- a/plugins/header_rewrite/header_rewrite.config
+++ /dev/null
@@ -1,94 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# 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 KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-Operators
----------
-rm-header Header matcher
-add-header Header value
-set-header Header value
-
-set-status value
-set-status-reason value
-
-
-Conditions
------------
-%{TRUE}  # Default condition if none specified
-%{FALSE}
-%{HEADER:string}
-%{YCOOKIE:id}
-%{METHOD}
-%{PROTOCOL}
-%{PORT}
-%{HOST}
-%{TOHOST}
-%{FROMHOST}
-%{PATH}
-%{PARAMS}
-%{QUERY}
-%{STATUS}
-
-# These can only be used as the first condition of a new ruleset,
-# and have no run-time evaluation effects (only config parse time).
-%{READ_RESPONSE_HDR_HOOK} # Default
-%{READ_REQUEST_HDR_HOOK}
-
-
-Operator Flags
---------------
-L    # Last rule (stop evaluations)
-
-
-Cond Flags
-----------
-NC   # Not case sensitive condition (when applicable)
-NOT  # Negate the cond
-OR   # Local OR between conds
-AND  # Logical AND betwen conds
-
-
-Matcher
---------
-
-/string/  # regular expression
-<string   # lexically lower
->string   # lexically greater
-=string   # lexically equal
-
-(The absense of a "matcher" means value exists).
-
-
-Values
-------
-
-Any of the cond definitions, that extracts a value from the request
-$N 0 <= N <= 9, as grouped in a regular expression
-string (which can contain the above)
-null
-
-
-Examples
---------
-
-cond %{HEADER:X-Y-Foobar}
-cond %{METHOD} =GET [OR]
-cond %{METHOD} =POST
-set-header X-Y-Fiefum %{HEADER:X-Y-Foobar}
-rm-header X-Y-Foobar
-rm-header Set-Cookie
-
-cond %{HEADER:X-Y-Foobar} "Some string" [AND,NC]