trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject git commit: TS-2229 header_filter should be deprecated, header_rewrite is a superset of functionality
Date Thu, 30 Jan 2014 23:37:56 GMT
Updated Branches:
  refs/heads/5.0.x 3a1fcd475 -> e08d57fb5


TS-2229 header_filter should be deprecated, header_rewrite is a superset of functionality


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

Branch: refs/heads/5.0.x
Commit: e08d57fb5614f9e597de02a97f0d159a9c27625e
Parents: 3a1fcd4
Author: Leif Hedstrom <zwoop@apache.org>
Authored: Thu Jan 30 16:34:51 2014 -0700
Committer: Leif Hedstrom <zwoop@apache.org>
Committed: Thu Jan 30 16:34:51 2014 -0700

----------------------------------------------------------------------
 CHANGES                                    |   2 +
 configure.ac                               |   1 -
 doc/reference/plugins/header_filter.en.rst | 132 ----------
 doc/reference/plugins/index.en.rst         |   1 -
 plugins/Makefile.am                        |   1 -
 plugins/header_filter/Makefile.am          |  21 --
 plugins/header_filter/README               |  95 -------
 plugins/header_filter/example.conf         |  38 ---
 plugins/header_filter/header_filter.cc     | 215 ---------------
 plugins/header_filter/lulu.h               |  76 ------
 plugins/header_filter/rules.cc             | 335 ------------------------
 plugins/header_filter/rules.h              | 176 -------------
 plugins/header_rewrite/header_rewrite.cc   |   7 +-
 13 files changed, 5 insertions(+), 1095 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 2ffd565..3aba18a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2229] Deprecate the header_filter plugin, use header_rewrite instead.
+
   *) [TS-2290] Remove X-ID special log tag, and cleanup HdrToken confusion.
 
   *) [TS-2088] Change TSRecordType enum values to powers of two

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 5823f2a..a195f01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1953,7 +1953,6 @@ AC_CONFIG_FILES([
   plugins/experimental/xdebug/Makefile
   plugins/gzip/Makefile
   plugins/libloader/Makefile
-  plugins/header_filter/Makefile
   plugins/header_rewrite/Makefile
   plugins/regex_remap/Makefile
   plugins/stats_over_http/Makefile

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/doc/reference/plugins/header_filter.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/header_filter.en.rst b/doc/reference/plugins/header_filter.en.rst
deleted file mode 100644
index 040e6d2..0000000
--- a/doc/reference/plugins/header_filter.en.rst
+++ /dev/null
@@ -1,132 +0,0 @@
-Header Filter Plugin
-********************
-
-.. 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.
-
-The ``header_filter`` is a simple plugin for filtering out headers from
-requests (or responses). Typical configuration is done either with a
-global configuration, in :file:`plugin.config`::
-
-    header_filter.so /usr/local/etc/hdr_filters.conf
-
-Or, alternatively, in a
-```per-remap`` <../../configuration-files/remap.config>`_ rule
-configuration ::
-
-    map http://a.com/ http://b.com @plugin=header_filter.so @pparam=hdr_filters.conf
-
-Even if you don't have a global configuration, if your remap rules
-schedules actions in hooks other than during remap, you must also add
-the ``header_filter.so`` to the
-```plugin.config`` <../../configuration-files/remap.config>`_ (see
-above), but without args::
-
-    header_filter.so
-
-The configuration files looks like ::
-
-    [READ_REQUEST_HDR]
-        X-From-Someone
-        Cookie
-
-    [READ_RESPONSE_HDR]
-        X-From-Server
-        Set-Cookie
-
-    [SEND_RESPONSE_HDR]
-        X-Fie "Test"    # Match the entire string
-        X-Foo /Test/    # Match the (Perl) regex
-        X-Bar [Test*    # Match the prefix string
-        X-Fum *Test]    # Match the postfix string
-
-
-Comments are prefixed with ``#``, and in most cases, the regular
-expression matching is the best choice (very little overhead). The
-pattern matches can also take an option '``!``\ ' to reverse the test.
-The default action is to delete all headers that do (not) match the
-pattern. E.g.::
-
-    [SEND_REQUEST_HDR]
-        X-Fie   /test/
-        X-Foo ! /test/i
-
-The final "``i``\ " qualifier (works on all pattern matches) forces the
-match or comparison to be made case insensitive (just like in Perl).
-
-It's also possible to replace or add headers, using the = and +
-operators. For example ::
-
-    [SEND_REQUEST_HDR]
-        Host =www.example.com=
-        X-Foo +ATS+
-
-This will force the Host: header to have exactly one value,
-``www.example.com``, while ``X-Foo`` will have at least one header with
-the value ATS, but there could be more instances of the header from the
-existing header in the request.
-
-Possible hooks are ::
-
-     READ_REQUEST_HDR
-     SEND_REQUEST_HDR
-     READ_RESPONSE_HDR
-     SEND_RESPONSE_HDR
-
-If not specified, the default hook to add the rules (headers to filter)
-is ``READ_REQUEST_HDR``. It's completely acceptable (and useful) to
-configure a remap rule to delete headers in a later hook (e.g. when
-reading a response from the server). This is what actually makes the
-plugin even remotely useful.
-
-
-Examples
-========
-
-Set X-Forwarded-Proto https on SSL connections
-----------------------------------------------
-
-Often times a backend wants to know whether it's running under HTTP or
-HTTPS. While not regulated standard, we can use the
-``X-Forwarded-Proto`` header for this purpose.
-
-In ```plugin.config`` <../../configuration-files/plugin.config>`_ we
-need to add::
-
-    header_filter.so
-
-Then, in ```remap.config`` <../../configuration-files/remap.config>`_ we
-can configure ``header_filter`` on a case by case basis::
-
-    map http://example.org http://172.16.17.42:8080
-    map https://example.org http://172.16.17.42:8080 @plugin=header_filter.so @pparam=/etc/trafficserver/x_fwd_proto.conf
-
-The configuration that ties everything together is then
-``/etc/trafficserver/x_fwd_proto.config``, to which we add::
-
-    [SEND_REQUEST_HDR]
-        X-Forwarded-Proto =https=
-
-To activate this configuration, we need to restart Traffic Server with
-:option:`traffic_line -L`.
-
-In the backend servers we can now pick this up and do appropriately set
-server variables that will be picked up by CGI programs for instance. In
-the case of Apache httpd backend, this can be acomplished with
-```mod_setenvif`` <http://httpd.apache.org/docs/current/mod/mod_setenvif.html#setenvif>`_::
-
-    SetEnvIf X-Forwarded-Proto https HTTPS=on SSL=on

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/doc/reference/plugins/index.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/index.en.rst b/doc/reference/plugins/index.en.rst
index 43a990f..db664b7 100644
--- a/doc/reference/plugins/index.en.rst
+++ b/doc/reference/plugins/index.en.rst
@@ -43,7 +43,6 @@ Apache Traffic Server releases.
   cacheurl.en
   conf_remap.en
   gzip.en
-  header_filter.en
   header_rewrite.en
   regex_remap.en
   stats_over_http.en

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/plugins/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 819af67..6e00ec5 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -20,7 +20,6 @@ SUBDIRS = \
   cacheurl \
   conf_remap \
   gzip \
-  header_filter \
   header_rewrite \
   libloader \
   regex_remap \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/plugins/header_filter/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/header_filter/Makefile.am b/plugins/header_filter/Makefile.am
deleted file mode 100644
index fc752bd..0000000
--- a/plugins/header_filter/Makefile.am
+++ /dev/null
@@ -1,21 +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.
-
-include $(top_srcdir)/build/plugins.mk
-
-pkglib_LTLIBRARIES = header_filter.la
-header_filter_la_SOURCES = header_filter.cc rules.cc
-header_filter_la_LDFLAGS = $(TS_PLUGIN_LDFLAGS)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/plugins/header_filter/README
----------------------------------------------------------------------
diff --git a/plugins/header_filter/README b/plugins/header_filter/README
deleted file mode 100644
index f10a9ac..0000000
--- a/plugins/header_filter/README
+++ /dev/null
@@ -1,95 +0,0 @@
-Apache Traffic Server Header Filter plugin
-==========================================
-
-This is a simple plugin for filtering out headers from requests (or
-responses). Typical configuration is done either with a global
-configuration, in .../etc/trafficserver/plugin.config:
-
-    header_filter.so /usr/local/etc/hdr_filters.conf
-
-
-Or, alternatively, in a per-remap rule configuration 
-
-    map http://a.com/ http://b.com @plugin=header_filter.so @pparam=hdr_filters.conf
-
-
-Even if you don't have a global configuration, if your remap rules
-schedules actions in hooks other than during remap, you must also add the
-header_filter.so to the plugin.config (see above), but without args:
-
-    header_filter.so
-
-
-The configuration files looks like
-
-[READ_REQUEST_HDR]
-	X-From-Someone
-	Cookie
-
-[READ_RESPONSE_HDR]
-	X-From-Server
-	Set-Cookie
-
-[SEND_RESPONSE_HDR]
-	X-Fie "Test"    # Match the entire string
-	X-Foo /Test/    # Match the (Perl) regex
-	X-Bar [Test*    # Match the prefix string
-	X-Fum *Test]    # Match the postfix string
-
-
-Comments are prefixed with #, and in most cases, the regular expression
-matching is the best choice (very little overhead). The pattern matches
-can also take an option '!' to reverse the test. The default action is
-to delete all headers that do (not) match the pattern. E.g.
-
-[SEND_REQUEST_HDR]
-	X-Fie   /test/
-	X-Foo ! /test/i
-
-
-The final "i" qualifier (works on all pattern matches) forces the match or
-comparison to be made case insensitive (just like in Perl).
-
-
-It's also possible to replace or add headers, using the = and +
-operators. For example
-
-[SEND_REQUEST_HDR]
-	Host =www.example.com=
-	X-Foo +ATS+
-
-
-This will force the Host: header to have exactly one value,
-www.example.com, while X-Foo will have at least one header with the value
-ATS, but there could be more instances of the header from the existing
-header in the request.
-
-
-Possible hooks are
-
-	 READ_REQUEST_HDR
-	 SEND_REQUEST_HDR
-	 READ_RESPONSE_HDR
-	 SEND_RESPONSE_HDR
-
-
-If not specified, the default hook to add the rules (headers to filter) is
-READ_REQUEST_HDR. It's completely acceptable (and useful) to configure a
-remap rule to delete headers in a later hook (e.g. when reading a response
-from the server). This is what actually makes the plugin even remotely
-useful.
-
-
-
-BUILDING
-========
-
-A simple
-
-    % make
-    % make install
-
-
-should do it, assuming that you have the tsxs script in your search
-path. This script is installed with your installation of Apache Traffic
-Server.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/plugins/header_filter/example.conf
----------------------------------------------------------------------
diff --git a/plugins/header_filter/example.conf b/plugins/header_filter/example.conf
deleted file mode 100644
index ab73743..0000000
--- a/plugins/header_filter/example.conf
+++ /dev/null
@@ -1,38 +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.
-#
-
-#
-# The following will:
-#    - nuke the cookie headers (all of them)
-#    - Replace the Host: header with www.ogre.com
-#    - Add a header X-Append-Header: Added by ATS
-#
-[READ_RESPONSE_HDR]
-  Set-Cookie
-  Expires
-  Vary /user-agent/i
-  X-Foo ! "test"
-
-
-#
-# There can only ever be one Host: header (the plugin assures that since we use the set-operator)
-# but there can be more than one X-Append-Header (since we use the add-operator).
-#
-[SEND_REQUEST_HDR]
-	Cookie
-	Host =www.ogre.com=
-	X-Append-Header +Added by ATS+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/plugins/header_filter/header_filter.cc
----------------------------------------------------------------------
diff --git a/plugins/header_filter/header_filter.cc b/plugins/header_filter/header_filter.cc
deleted file mode 100644
index 9a9f690..0000000
--- a/plugins/header_filter/header_filter.cc
+++ /dev/null
@@ -1,215 +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.
-*/
-
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-// 
-// Main entry points for the plugin hooks etc.
-//
-#include "ts/ts.h"
-#include "ts/remap.h"
-#include "ink_config.h"
-
-#include <stdio.h>
-
-#include "rules.h"
-
-using namespace ::HeaderFilter;
-
-// Global plugin rules
-Rules global;
-int arg_idx;
-
-// TODO: Maybe we should use wrappers for TSmalloc() for pcre_malloc (and _free),
-// but since we only compile at config time, it's really not that important.
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Continuation
-//
-static int
-cont_header_filter(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
-{
-  TSHttpTxn txnp = (TSHttpTxn) edata;
-  TSHttpHookID hook = TS_HTTP_LAST_HOOK;
-  TSMBuffer reqp;
-  TSMLoc hdr_loc;
-
-  // Get the resources necessary to process this event
-  switch (event) {
-  case TS_EVENT_HTTP_READ_REQUEST_HDR:
-    if (TS_SUCCESS == TSHttpTxnClientReqGet(txnp, &reqp, &hdr_loc))
-      hook = TS_HTTP_READ_REQUEST_HDR_HOOK;
-    break;
-  case TS_EVENT_HTTP_SEND_REQUEST_HDR:
-    if (TS_SUCCESS == TSHttpTxnServerReqGet(txnp, &reqp, &hdr_loc))
-      hook = TS_HTTP_SEND_REQUEST_HDR_HOOK;
-    break;
-  case TS_EVENT_HTTP_READ_RESPONSE_HDR:
-    if (TS_SUCCESS == TSHttpTxnServerRespGet(txnp, &reqp, &hdr_loc))
-      hook = TS_HTTP_READ_RESPONSE_HDR_HOOK;
-    break;
-  case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
-    if (TS_SUCCESS == TSHttpTxnClientRespGet(txnp, &reqp, &hdr_loc))
-      hook = TS_HTTP_SEND_RESPONSE_HDR_HOOK;
-    break;
-  default:
-    TSError("header_filter: unknown event for this plugin");
-    TSDebug(PLUGIN_NAME, "unknown event for this plugin");
-    break;
-  }
-
-  if (hook != TS_HTTP_LAST_HOOK) {
-    Rules* from_remap;
-
-    global.execute(reqp, hdr_loc, hook);
-
-    if (TS_HTTP_READ_REQUEST_HDR_HOOK != hook) { // Don't run the hook handled by remap plugin
-      if ((from_remap = (Rules*)TSHttpTxnArgGet(txnp, arg_idx))) {
-        from_remap->execute(reqp, hdr_loc, hook);
-      }
-    }
-    TSHandleMLocRelease(reqp, TS_NULL_MLOC, hdr_loc);
-  }
-
-  TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
-  return 0;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Initialize the InkAPI plugin for the global hooks we support.
-//
-void
-TSPluginInit(int argc, const char *argv[])
-{
-  TSPluginRegistrationInfo info;
-
-  info.plugin_name = const_cast<char*>(PLUGIN_NAME);
-  info.vendor_name = const_cast<char*>("Apache Software Foundation");
-  info.support_email = const_cast<char*>("dev@trafficserver.apache.org");
-
-  if (TSPluginRegister(TS_SDK_VERSION_3_0 , &info) != TS_SUCCESS) {
-    TSError("header_filter: plugin registration failed.\n"); 
-  }
-
-  // Parse the rules file
-  if ((argc > 1)) {
-    if (!global.parse_file(argv[1]))
-      TSError("header_filter: failed to parse configuration file");
-  }
-
-  TSCont cont = TSContCreate(cont_header_filter, NULL);
-
-  for (int i=TS_HTTP_READ_REQUEST_HDR_HOOK; i < TS_HTTP_LAST_HOOK; ++i) {
-    if (global.supported_hook(static_cast<TSHttpHookID>(i))) {
-      TSDebug(PLUGIN_NAME, "Registering hook %d", i);
-      TSHttpHookAdd(static_cast<TSHttpHookID>(i), cont);
-    }
-  }
-  if (TSHttpArgIndexReserve(PLUGIN_NAME, "Filter out headers in various hooks", &arg_idx)
!= TS_SUCCESS) {
-    TSError("header_filter: failed to reserve private data slot");
-  }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Initialize the plugin as a remap plugin.
-//
-TSReturnCode
-TSRemapInit(TSRemapInterface* api_info, char *errbuf, int errbuf_size)
-{
-  if (!api_info) {
-    strncpy(errbuf, "[tsremap_init] - Invalid TSRemapInterface argument", errbuf_size - 1);
-    return TS_ERROR;
-  }
-
-  if (api_info->size < sizeof(TSRemapInterface)) {
-    strncpy(errbuf, "[tsremap_init] - Incorrect size of TSRemapInterface structure", errbuf_size
- 1);
-    return TS_ERROR;
-  }
-
-  if (api_info->tsremap_version < TSREMAP_VERSION) {
-    snprintf(errbuf, errbuf_size - 1, "[tsremap_init] - Incorrect API version %ld.%ld",
-             api_info->tsremap_version >> 16, (api_info->tsremap_version &
0xffff));
-    return TS_ERROR;
-  }
-
-  TSDebug(PLUGIN_NAME, "remap plugin is successfully initialized");
-  return TS_SUCCESS;                     /* success */
-}
-
-
-TSReturnCode
-TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED */, int
/* errbuf_size */)
-{
-  if (argc < 3) {
-    TSError("Unable to create remap instance, need rules file");
-    return TS_ERROR;
-  } else {
-    Rules* conf = new(Rules);
-
-    conf->parse_file(argv[2]);
-    *ih = static_cast<void*>(conf);
-  }
-
-  return TS_SUCCESS;
-}
-
-void
-TSRemapDeleteInstance(void* ih)
-{
-  Rules* conf = static_cast<Rules*>(ih);
-
-  delete conf;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Main entry point when used as a remap plugin.
-//
-TSRemapStatus
-TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
-{
-  if (NULL == ih) {
-    TSDebug(PLUGIN_NAME, "No Rules configured, falling back to default mapping rule");
-  } else {
-    Rules* confp = static_cast<Rules*>(ih);
-
-    TSHttpTxnArgSet(rh, arg_idx, static_cast<void*>(ih)); // Save for later hooks
-    confp->execute(rri->requestBufp, rri->requestHdrp, TS_HTTP_READ_REQUEST_HDR_HOOK);
-  }
-
-  return TSREMAP_NO_REMAP;
-}
-
-
-/*
-  local variables:
-  mode: C++
-  indent-tabs-mode: nil
-  c-basic-offset: 2
-  c-comment-only-line-offset: 0
-  c-file-offsets: ((statement-block-intro . +)
-  (label . 0)
-  (statement-cont . +)
-  (innamespace . 0))
-  end:
-
-  Indent with: /usr/bin/indent -ncs -nut -npcs -l 120 logstats.cc
-*/

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/plugins/header_filter/lulu.h
----------------------------------------------------------------------
diff --git a/plugins/header_filter/lulu.h b/plugins/header_filter/lulu.h
deleted file mode 100644
index 24cc165..0000000
--- a/plugins/header_filter/lulu.h
+++ /dev/null
@@ -1,76 +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.
-*/
-
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-// 
-// Implement the classes for the various types of hash keys we support.
-//
-#ifndef __LULU_H__
-#define __LULU_H__ 1
-
-#include <sys/types.h>
-
-#include "ink_atomic.h"
-
-// Memory barriers on i386 / linux / gcc
-#if defined(__i386__)
-#define mb()  __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define wmb() __asm__ __volatile__ ( "" : : : "memory")
-#elif defined(__x86_64__)
-#define mb()  __asm__ __volatile__ ( "mfence" : : : "memory")
-#define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
-#define wmb() __asm__ __volatile__ ( "" : : : "memory")
-#elif defined(__arm__)
-#define mb()  __asm__ __volatile__ ( "dmb" : : : "memory")
-#define rmb() __asm__ __volatile__ ( "dmb" : : : "memory")
-#define wmb() __asm__ __volatile__ ( "" : : : "memory")
-#elif defined(__arm__)
-#else
-#error "Define barriers"
-#endif
-
-// Used for Debug etc.
-static const char* PLUGIN_NAME = "header_filter";
-static const char* PLUGIN_NAME_DBG = "header_filter_dbg";
-
-// From google styleguide: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
-#define DISALLOW_COPY_AND_ASSIGN(TypeName)      \
-  TypeName(const TypeName&);                    \
-  void operator=(const TypeName&)
-
-
-#endif // __LULU_H__
-
-
-
-/*
-  local variables:
-  mode: C++
-  indent-tabs-mode: nil
-  c-basic-offset: 2
-  c-comment-only-line-offset: 0
-  c-file-offsets: ((statement-block-intro . +)
-  (label . 0)
-  (statement-cont . +)
-  (innamespace . 0))
-  end:
-
-  Indent with: /usr/bin/indent -ncs -nut -npcs -l 120 logstats.cc
-*/

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/plugins/header_filter/rules.cc
----------------------------------------------------------------------
diff --git a/plugins/header_filter/rules.cc b/plugins/header_filter/rules.cc
deleted file mode 100644
index feebc04..0000000
--- a/plugins/header_filter/rules.cc
+++ /dev/null
@@ -1,335 +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.
-*/
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-// 
-// Implemenation details for the rules class.
-//
-#include <fstream>
-#include <ts/ts.h>
-
-#include "rules.h"
-
-namespace HeaderFilter {
-
-const char* QUAL_DELIMITERS = "!/\"*[+=";
-
-
-// RulesEntry implementations
-void
-RulesEntry::append(RulesEntry* entry)
-{
-  RulesEntry* n = this;
-
-  while (NULL != n->_next)
-    n = n->_next;
-  n->_next = entry;
-}
-
-inline void
-add_header(TSMBuffer& reqp, TSMLoc& hdr_loc, const char* hdr, int hdr_len, const
char* val, int val_len)
-{
-  if (val_len <= 0) {
-    TSDebug(PLUGIN_NAME, "\tWould set header %s to an empty value, skipping", hdr);
-  } else {
-    TSMLoc new_field;
-
-    if (TS_SUCCESS == TSMimeHdrFieldCreateNamed(reqp, hdr_loc, hdr, hdr_len, &new_field))
{
-      if (TS_SUCCESS == TSMimeHdrFieldValueStringInsert(reqp, hdr_loc, new_field, -1,  val,
val_len))
-        if (TS_SUCCESS == TSMimeHdrFieldAppend(reqp, hdr_loc, new_field))
-          TSDebug(PLUGIN_NAME, "\tAdded header %s: %s", hdr, val);
-      TSHandleMLocRelease(reqp, hdr_loc, new_field);
-    }
-  }
-}
-
-void
-RulesEntry::execute(TSMBuffer& reqp, TSMLoc& hdr_loc) const
-{
-  if (_q_type == QUAL_ADD) {
-    add_header(reqp, hdr_loc, _header, _h_len, _qualifier, _q_len);
-  } else {
-    TSMLoc field = TSMimeHdrFieldFind(reqp, hdr_loc, _header, _h_len);
-    bool first_set = true;
-
-    if (!field && _q_type == QUAL_SET) {
-      add_header(reqp, hdr_loc, _header, _h_len, _qualifier, _q_len);
-    } else {
-      while (field) {
-        TSMLoc tmp;
-        int val_len = 0;
-        const char* val = NULL;
-        bool nuke = false;
-      
-        if (_q_type != QUAL_NONE)
-          val = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field, -1, &val_len);
-
-        switch (_q_type) {
-        case QUAL_NONE:
-          nuke = true;
-          break;
-        case QUAL_REGEX:
-          if (val_len > 0) {
-            nuke = pcre_exec(_rex,            // the compiled pattern
-                             _extra,          // Extra data from study (maybe)
-                             val,                // the subject string
-                             val_len,            // the length of the subject
-                             0,                  // start at offset 0 in the subject
-                             0,                  // default options
-                             NULL,               // no output vector for substring information
-                             0) >= 0;
-          }
-          break;
-
-        case QUAL_STRING:
-          if (static_cast<size_t>(val_len) == _q_len) {
-            if (_options & PCRE_CASELESS) {
-              nuke = !strncasecmp(_qualifier, val, val_len);
-            } else {
-              nuke = !memcmp(_qualifier, val, val_len);
-            }
-          }
-          break;
-
-        case QUAL_PREFIX:
-          if (static_cast<size_t>(val_len) >= _q_len) {
-            if (_options & PCRE_CASELESS) {
-              nuke = !strncasecmp(_qualifier, val, _q_len);
-            } else {
-              nuke = !memcmp(_qualifier, val, _q_len);
-            }
-          }
-          break;
-
-        case QUAL_POSTFIX: 
-          if (static_cast<size_t>(val_len) >= _q_len) {
-            if (_options & PCRE_CASELESS) {
-              nuke = !strncasecmp(_qualifier, val + val_len - _q_len, _q_len);
-            } else {
-              nuke = !memcmp(_qualifier, val + val_len - _q_len, _q_len);
-            }
-          }
-          break;
-        case QUAL_SET:
-          if (first_set) {
-            nuke = false;
-            first_set = false;
-            if (TS_SUCCESS == TSMimeHdrFieldValueStringSet(reqp, hdr_loc, field, -1, _qualifier,
_q_len))
-              TSDebug(PLUGIN_NAME, "\tSet header:  %s: %s", _header, _qualifier);
-          } else {
-            // Nuke all other "duplicates" of this header
-            nuke = true;
-          }
-        
-        default:
-          break;
-        }
-
-        tmp = TSMimeHdrFieldNextDup(reqp, hdr_loc, field);
-        if (_inverse)
-          nuke = !nuke;
-        if (nuke) {
-          if (TS_SUCCESS == TSMimeHdrFieldDestroy(reqp, hdr_loc, field))
-            TSDebug(PLUGIN_NAME, "\tDeleting header %.*s", static_cast<int>(_h_len),
_header);
-        }
-        TSHandleMLocRelease(reqp, hdr_loc, field);
-        field = tmp;
-      }
-    }
-  }
-}
-
-
-// Rules class implementations
-Rules::~Rules()
-{
-  TSDebug(PLUGIN_NAME_DBG, "Calling DTOR for Rules");
-
-  for (int i = 0; i < TS_HTTP_LAST_HOOK; ++i)
-    delete _entries[i];
-}
-
-RulesEntry*
-Rules::add_entry(const TSHttpHookID hook, const std::string& s, const std::string&
q, QualifierTypes type, bool inverse, int options)
-{
-  RulesEntry* e = new(RulesEntry)(s, q, type, inverse, options);
-
-  TSAssert(supported_hook(hook));
-  if (NULL == _entries[hook]) {
-    _entries[hook] = e;
-  } else {
-    _entries[hook]->append(e);
-  }
-  
-  return e;
-}
-
-bool
-Rules::parse_file(const char* filename)
-{
-  std::ifstream f;
-  TSHttpHookID hook = TS_HTTP_READ_REQUEST_HDR_HOOK;
-  int lineno = 0;
-
-  // TODO: Should we support "glob" here, to specify more than one filename?
-  // TODO: Should we support a 'default' prefix here for the rules?
-  f.open(filename, std::ios::in);
-  if (!f.is_open()) {
-    TSError("unable to open %s", filename);
-    return false;
-  }
-  TSDebug(PLUGIN_NAME, "Parsing config file %s", filename);
-  while (!f.eof()) {
-    bool inverse = false;
-    int options = 0;
-    QualifierTypes type = QUAL_NONE;
-    std::string line, word, qualifier;
-    std::string::size_type pos1, pos2;
-
-    getline(f, line);
-    ++lineno;
-    if (line.empty())
-      continue;
-
-    pos1 = line.find_first_not_of(" \t\n");
-    if (pos1 != std::string::npos) {
-      if (line[pos1] == '#') {
-        continue; // Skip comments
-      } else {
-        pos2 = line.find_first_of("# \t\n", pos1+1); // end of word
-        if (pos2 == std::string::npos) {
-          word = line.substr(pos1);
-          pos1 = pos2;
-        } else {
-          word = line.substr(pos1, pos2-pos1);
-          pos1 = line.find_first_of(QUAL_DELIMITERS, pos2+1);
-        }
-
-        if (word == "[READ_REQUEST_HDR]") {
-          hook = TS_HTTP_READ_REQUEST_HDR_HOOK;
-        } else if (word == "[SEND_REQUEST_HDR]") {
-          hook = TS_HTTP_SEND_REQUEST_HDR_HOOK;
-        } else if (word == "[READ_RESPONSE_HDR]") {
-          hook = TS_HTTP_READ_RESPONSE_HDR_HOOK;
-        } else if (word == "[SEND_RESPONSE_HDR]") {
-          hook = TS_HTTP_SEND_RESPONSE_HDR_HOOK;
-        } else  if (word.empty()) {
-          // Error case, but shouldn't happen?
-        } else {
-          // Treat everything else as headers (+ possibly a qualifier)
-          if (pos1 != std::string::npos) { // Found a specifier
-            if (line[pos1] == '!') {
-              inverse = true;
-              pos1 =  line.find_first_of(QUAL_DELIMITERS, pos1+1);
-            }
-            if (pos1 != std::string::npos) {
-              char trailer = ' ';
-
-              switch (line[pos1]) {
-              case '/':
-                type = QUAL_REGEX;
-                trailer = '/';
-                break;
-              case '"':
-                type = QUAL_STRING;
-                trailer = '"';
-                break;
-              case '*':
-                type = QUAL_POSTFIX;
-                trailer = ']';
-                break;
-              case '[':
-                type = QUAL_PREFIX;
-                trailer = '*';
-                break;
-              case '+':
-                type = QUAL_ADD;
-                inverse = false; // Can never inverse the add operator
-                trailer = '+';
-                break;
-              case '=':
-                type = QUAL_SET;
-                inverse = false; // Can never inverse the set operator
-                trailer = '=';
-                break;
-              default:
-                // TODO: Error case?
-                break;
-              }
-                
-              pos2 = line.find_last_of(trailer);
-              if (pos2 != std::string::npos) {
-                qualifier = line.substr(pos1+1, pos2-pos1-1);
-                if (line[pos2+1] == 'i')
-                  options |= PCRE_CASELESS;
-                TSDebug(PLUGIN_NAME, "Adding '%s' to hook %d, type is %d, qualifier is %c
%s (%c)",
-                        word.c_str(), hook, type, inverse ? '!' : ' ', qualifier.c_str(),
options & PCRE_CASELESS ? 'i' : ' ');
-                add_entry(hook, word, qualifier, type, inverse, options);
-              } else {
-                TSError("Missing trailing delimiter in qualifier");
-              }
-            } else {
-              TSError("Missing leading delimiter in qualifier");
-            }
-          } else {
-            // No qualifier, so we'll nuke this header for all values
-            TSDebug(PLUGIN_NAME, "Adding %s to hook %d (unqualified)", word.c_str(), hook);
-            add_entry(hook, word);
-          }
-        }
-      }
-    }
-  }
-
-  return true;
-}
-
-
-void
-Rules::execute(TSMBuffer& reqp, TSMLoc& hdr_loc, const TSHttpHookID hook) const
-{
-  TSAssert(supported_hook(hook));
-
-  if (_entries[hook]) {
-    RulesEntry* n = _entries[hook];
-
-    TSDebug(PLUGIN_NAME, "Executing rules(s) for hook %d", hook);
-    do {
-      n->execute(reqp, hdr_loc);
-    } while (NULL != (n = n->next()));
-  }
-}
-
-
-} // End of namespace ::HeaderFilter
-
-
-/*
-  local variables:
-  mode: C++
-  indent-tabs-mode: nil
-  c-basic-offset: 2
-  c-comment-only-line-offset: 0
-  c-file-offsets: ((statement-block-intro . +)
-  (label . 0)
-  (statement-cont . +)
-  (innamespace . 0))
-  end:
-
-  Indent with: /usr/bin/indent -ncs -nut -npcs -l 120 logstats.cc
-*/

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/plugins/header_filter/rules.h
----------------------------------------------------------------------
diff --git a/plugins/header_filter/rules.h b/plugins/header_filter/rules.h
deleted file mode 100644
index 70e3756..0000000
--- a/plugins/header_filter/rules.h
+++ /dev/null
@@ -1,176 +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.
-*/
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-// 
-// Class for holding a set of configurations. There would be one global configuration, used
-// by all hooks / requests, and one optional configuration for each remap rule.
-//
-#ifndef __RULES_H__
-#define __RULES_H__ 1
-
-#include "ts/ts.h"
-#include "ink_config.h"
-
-#include <string>
-#include <string.h>
-
-#ifdef HAVE_PCRE_PCRE_H
-#include <pcre/pcre.h>
-#else
-#include <pcre.h>
-#endif
-
-#include "lulu.h"
-
-namespace HeaderFilter {
-
-// The delimiters might look arbitrary, but are choosen to make parsing trivial
-enum QualifierTypes {
-  QUAL_NONE = 0,
-  QUAL_REGEX = 1,		// Regular expression, /match/
-  QUAL_STRING = 2,		// Full string, "match"
-  QUAL_PREFIX = 3,		// Sub-string prefix, [match*
-  QUAL_POSTFIX = 4,		// Sub-string postfix, *match]
-  // This is a semi-hack, but whatever (for now, until we get Lua module done!
-  QUAL_ADD = 5,			// Add the header +string+
-  QUAL_SET = 6			// Set the header =string=, leaving only one header with the new value
-};
-
-
-class RulesEntry
-{
-public:
-  RulesEntry(const std::string& s, const std::string& q, QualifierTypes type, bool
inverse, int options)
-    : _header(NULL), _h_len(0), _qualifier(NULL), _q_len(0), _q_type(type), _rex(NULL), _extra(NULL),
-      _inverse(inverse), _options(options), _next(NULL)
-  {
-    if (s.length() > 0) {
-      _header = TSstrdup(s.c_str());
-      _h_len = s.length();
-    }
-    
-    if (q.length() > 0) {
-      _qualifier = TSstrdup(q.c_str());
-      _q_len = q.length();
-      if (_q_type == QUAL_REGEX) {
-        const char* error;
-        int erroffset;
-
-        _rex = pcre_compile(_qualifier,           // the pattern
-                            _options,             // default options
-                            &error,               // for error message
-                            &erroffset,           // for error offset
-                            NULL);                // use default character tables
-        if (!_rex)
-          TSError("header_filter: PCRE failed on %s at offset %d: %s\n", _qualifier, erroffset,
error);
-      }
-    }
-
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for RulesEntry, header is %s, qualifier is %s",
_header, _qualifier);
-  }
-
-  ~RulesEntry()
-  {
-    TSDebug(PLUGIN_NAME_DBG, "Calling DTOR for RulesEntry");
-    delete _next; // Potentially "deep" recursion, but should be OK.
-    if (_header)
-      TSfree(_header);
-
-    if (QUAL_REGEX == _q_type) {
-      if (_rex)
-        pcre_free(_rex);
-      if (_extra)
-        pcre_free(_extra);
-    }
-    if (_qualifier)
-      TSfree(_qualifier);
-  }
-
-  void append(RulesEntry* entry);
-  void execute(TSMBuffer& reqp, TSMLoc& hdr_loc) const; // This is really the meat
of the app
-  RulesEntry* next() const { return _next; }
-
-private:
-  DISALLOW_COPY_AND_ASSIGN(RulesEntry);
-
-  char* _header;
-  size_t _h_len;
-  char* _qualifier;
-  size_t _q_len;
-  QualifierTypes _q_type;
-  pcre* _rex;
-  pcre_extra* _extra;
-  bool _inverse;
-  int _options;
-  RulesEntry* _next;
-};
-
-
-class Rules
-{
-public:
-  Rules()
-  {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for Rules");
-    memset(_entries, 0, sizeof(_entries));
-  }
-
-  virtual ~Rules();
-
-  RulesEntry* add_entry(const TSHttpHookID hook, const std::string& s, const std::string&
q="", QualifierTypes type = QUAL_NONE,
-                        bool inverse=false, int options=0);
-  bool parse_file(const char* filename);
-
-  bool supported_hook(const TSHttpHookID hook) const
-  {
-    return ((hook == TS_HTTP_READ_REQUEST_HDR_HOOK) ||
-	    (hook == TS_HTTP_SEND_REQUEST_HDR_HOOK) ||
-	    (hook == TS_HTTP_READ_RESPONSE_HDR_HOOK) ||
-	    (hook == TS_HTTP_SEND_RESPONSE_HDR_HOOK));
-  }
-
-  void execute(TSMBuffer& reqp, TSMLoc& hdr_loc, const TSHttpHookID hook) const;
-
-private:
-  DISALLOW_COPY_AND_ASSIGN(Rules);
-
-  RulesEntry* _entries[TS_HTTP_LAST_HOOK]; // One possible set of entries for each hook
-};
-
-} // End of namespace ::HeaderFilter
-
-
-#endif // __RULES_H__
-
-
-
-/*
-  local variables:
-  mode: C++
-  indent-tabs-mode: nil
-  c-basic-offset: 2
-  c-comment-only-line-offset: 0
-  c-file-offsets: ((statement-block-intro . +)
-  (label . 0)
-  (statement-cont . +)
-  (innamespace . 0))
-  end:
-
-  Indent with: /usr/bin/indent -ncs -nut -npcs -l 120 logstats.cc
-*/

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e08d57fb/plugins/header_rewrite/header_rewrite.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/header_rewrite.cc b/plugins/header_rewrite/header_rewrite.cc
index 3bcb21d..6fc7960 100644
--- a/plugins/header_rewrite/header_rewrite.cc
+++ b/plugins/header_rewrite/header_rewrite.cc
@@ -346,10 +346,9 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
   } else {
     RulesConfig* conf = static_cast<RulesConfig*>(ih);
 
-    // ToDo: Would it be faster / better to register the global hook for all
-    // hooks, as we do in header_filter, regardless if there's a known config
-    // for that hook? For now, we assume it's cheaper / faster to create a
-    // TXN hook when necessary.
+    // TODO: We should optimize this to not create continuations every time,
+    // but instead save the continuations, with configurations, as the per
+    // remap instance data.
 
     // Go through all hooks we support, and setup the txn hook(s) as necessary
     for (int i=TS_HTTP_READ_REQUEST_HDR_HOOK; i<TS_HTTP_LAST_HOOK; ++i) {


Mime
View raw message