You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by br...@apache.org on 2014/03/06 21:47:02 UTC

[2/2] git commit: intercept support in atscppapi

intercept support in atscppapi


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

Branch: refs/heads/master
Commit: b4c34003301694dc5a26498382c4446364d4a2eb
Parents: 79ae4a1
Author: Manjesh Nilange <ma...@yahoo.com>
Authored: Thu Mar 6 12:36:54 2014 -0800
Committer: Manjesh Nilange <ma...@yahoo.com>
Committed: Thu Mar 6 12:36:54 2014 -0800

----------------------------------------------------------------------
 configure.ac                                  |  1 +
 lib/atscppapi/examples/Makefile.am            |  3 +-
 lib/atscppapi/examples/intercept/Makefile.am  | 24 ++++++++++
 lib/atscppapi/examples/intercept/intercept.cc | 55 ++++++++++++++++++++++
 lib/atscppapi/src/Makefile.am                 |  6 ++-
 lib/atscppapi/src/include/utils_internal.h    |  6 +++
 6 files changed, 92 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 875f2c4..7460f7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1937,6 +1937,7 @@ AC_CONFIG_FILES([
   lib/atscppapi/examples/timeout_example/Makefile
   lib/atscppapi/examples/internal_transaction_handling/Makefile
   lib/atscppapi/examples/async_timer/Makefile
+  lib/atscppapi/examples/intercept/Makefile
   lib/wccp/Makefile
   lib/perl/Makefile
   lib/perl/lib/Apache/TS.pm

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/examples/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/atscppapi/examples/Makefile.am b/lib/atscppapi/examples/Makefile.am
index 23c9c70..9cbf7d6 100644
--- a/lib/atscppapi/examples/Makefile.am
+++ b/lib/atscppapi/examples/Makefile.am
@@ -33,4 +33,5 @@ SUBDIRS = helloworld \
 	  gzip_transformation \
 	  timeout_example \
       internal_transaction_handling \
-      async_timer
\ No newline at end of file
+      async_timer \
+      intercept
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/examples/intercept/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/atscppapi/examples/intercept/Makefile.am b/lib/atscppapi/examples/intercept/Makefile.am
new file mode 100644
index 0000000..2400a10
--- /dev/null
+++ b/lib/atscppapi/examples/intercept/Makefile.am
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2013 LinkedIn Corp. All rights reserved. 
+# Licensed 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.
+#
+
+AM_CPPFLAGS = -I$(top_srcdir)/src/include
+
+target=intercept.so
+pkglibdir = ${pkglibexecdir}
+pkglib_LTLIBRARIES = intercept.la
+intercept_la_SOURCES = intercept.cc
+intercept_la_LDFLAGS = -module -avoid-version -shared -L$(top_srcdir) -latscppapi
+
+all:
+	ln -sf .libs/$(target)
+
+clean-local:
+	rm -f $(target)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/examples/intercept/intercept.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/examples/intercept/intercept.cc b/lib/atscppapi/examples/intercept/intercept.cc
new file mode 100644
index 0000000..4c98782
--- /dev/null
+++ b/lib/atscppapi/examples/intercept/intercept.cc
@@ -0,0 +1,55 @@
+#include <atscppapi/GlobalPlugin.h>
+#include <atscppapi/InterceptPlugin.h>
+#include <atscppapi/PluginInit.h>
+
+#include <iostream>
+
+using namespace atscppapi;
+using std::string;
+using std::cout;
+using std::endl;
+
+class Intercept : public InterceptPlugin {
+public:
+  Intercept(Transaction &transaction) : InterceptPlugin(transaction, InterceptPlugin::SERVER_INTERCEPT) { }
+  void consume(const string &data, InterceptPlugin::RequestDataType type);
+  void handleInputComplete();
+  ~Intercept() { cout << "Shutting down" << endl; }
+};
+
+class InterceptInstaller : public GlobalPlugin {
+public:
+  InterceptInstaller() : GlobalPlugin(true /* ignore internal transactions */) {
+    GlobalPlugin::registerHook(Plugin::HOOK_READ_REQUEST_HEADERS_PRE_REMAP);
+  }
+  void handleReadRequestHeadersPreRemap(Transaction &transaction) {
+    transaction.addPlugin(new Intercept(transaction));
+    cout << "Added intercept" << endl;
+    transaction.resume();
+  }
+};
+
+void TSPluginInit(int argc, const char *argv[]) {
+  new InterceptInstaller();
+}
+
+void Intercept::consume(const string &data, InterceptPlugin::RequestDataType type) {
+  if (type == InterceptPlugin::REQUEST_HEADER) {
+    cout << "Read request header data" << endl << data;
+  }
+  else {
+    cout << "Read request body data" << endl << data << endl;
+  }
+}
+
+void Intercept::handleInputComplete() {
+  cout << "Request data complete" << endl;
+  string response("HTTP/1.1 200 OK\r\n"
+                  "Content-Length: 7\r\n"
+                  "\r\n");
+  InterceptPlugin::produce(response);
+//  sleep(5); TODO: this is a test for streaming; currently doesn't work
+  response = "hello\r\n";
+  InterceptPlugin::produce(response);
+  InterceptPlugin::setOutputComplete();
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/src/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/Makefile.am b/lib/atscppapi/src/Makefile.am
index 4e7d204..346bdee 100644
--- a/lib/atscppapi/src/Makefile.am
+++ b/lib/atscppapi/src/Makefile.am
@@ -51,7 +51,8 @@ libatscppapi_la_SOURCES = GlobalPlugin.cc \
 			  RemapPlugin.cc \
 			  GzipDeflateTransformation.cc \
 			  GzipInflateTransformation.cc \
-			  AsyncTimer.cc
+			  AsyncTimer.cc \
+                          InterceptPlugin.cc
 
 library_includedir=$(includedir)/atscppapi
 base_include_folder = include/atscppapi/
@@ -82,4 +83,5 @@ library_include_HEADERS = $(base_include_folder)/GlobalPlugin.h \
 			  $(base_include_folder)/AsyncHttpFetch.h \
 			  $(base_include_folder)/GzipDeflateTransformation.h \
 			  $(base_include_folder)/GzipInflateTransformation.h \
-			  $(base_include_folder)/AsyncTimer.h
+			  $(base_include_folder)/AsyncTimer.h \
+			  $(base_include_folder)/InterceptPlugin.h

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/src/include/utils_internal.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/utils_internal.h b/lib/atscppapi/src/include/utils_internal.h
index 0eb499e..c6ead71 100644
--- a/lib/atscppapi/src/include/utils_internal.h
+++ b/lib/atscppapi/src/include/utils_internal.h
@@ -37,6 +37,7 @@
 #include "atscppapi/utils.h"
 #include "atscppapi/AsyncHttpFetch.h"
 #include "atscppapi/Transaction.h"
+#include "atscppapi/InterceptPlugin.h"
 
 namespace atscppapi {
 
@@ -80,6 +81,11 @@ public:
   static const std::list<TransactionPlugin *> &getTransactionPlugins(const Transaction &transaction) {
     return transaction.getPlugins();
   }
+
+  static void dispatchInterceptEvent(InterceptPlugin *plugin, TSEvent event, void *edata) {
+    plugin->handleEvent(static_cast<int>(event), edata);
+  }
+
 }; /* internal */
 
 } /* utils */


Re: [2/2] git commit: intercept support in atscppapi

Posted by James Peach <jp...@apache.org>.
We should have a JIRA ticket for this so that we can publish accurate change logs and release notes


On Mar 6, 2014, at 12:47 PM, briang@apache.org wrote:

> intercept support in atscppapi
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/b4c34003
> Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/b4c34003
> Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/b4c34003
> 
> Branch: refs/heads/master
> Commit: b4c34003301694dc5a26498382c4446364d4a2eb
> Parents: 79ae4a1
> Author: Manjesh Nilange <ma...@yahoo.com>
> Authored: Thu Mar 6 12:36:54 2014 -0800
> Committer: Manjesh Nilange <ma...@yahoo.com>
> Committed: Thu Mar 6 12:36:54 2014 -0800
> 
> ----------------------------------------------------------------------
> configure.ac                                  |  1 +
> lib/atscppapi/examples/Makefile.am            |  3 +-
> lib/atscppapi/examples/intercept/Makefile.am  | 24 ++++++++++
> lib/atscppapi/examples/intercept/intercept.cc | 55 ++++++++++++++++++++++
> lib/atscppapi/src/Makefile.am                 |  6 ++-
> lib/atscppapi/src/include/utils_internal.h    |  6 +++
> 6 files changed, 92 insertions(+), 3 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/configure.ac
> ----------------------------------------------------------------------
> diff --git a/configure.ac b/configure.ac
> index 875f2c4..7460f7c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1937,6 +1937,7 @@ AC_CONFIG_FILES([
>   lib/atscppapi/examples/timeout_example/Makefile
>   lib/atscppapi/examples/internal_transaction_handling/Makefile
>   lib/atscppapi/examples/async_timer/Makefile
> +  lib/atscppapi/examples/intercept/Makefile
>   lib/wccp/Makefile
>   lib/perl/Makefile
>   lib/perl/lib/Apache/TS.pm
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/examples/Makefile.am
> ----------------------------------------------------------------------
> diff --git a/lib/atscppapi/examples/Makefile.am b/lib/atscppapi/examples/Makefile.am
> index 23c9c70..9cbf7d6 100644
> --- a/lib/atscppapi/examples/Makefile.am
> +++ b/lib/atscppapi/examples/Makefile.am
> @@ -33,4 +33,5 @@ SUBDIRS = helloworld \
> 	  gzip_transformation \
> 	  timeout_example \
>       internal_transaction_handling \
> -      async_timer
> \ No newline at end of file
> +      async_timer \
> +      intercept
> \ No newline at end of file
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/examples/intercept/Makefile.am
> ----------------------------------------------------------------------
> diff --git a/lib/atscppapi/examples/intercept/Makefile.am b/lib/atscppapi/examples/intercept/Makefile.am
> new file mode 100644
> index 0000000..2400a10
> --- /dev/null
> +++ b/lib/atscppapi/examples/intercept/Makefile.am
> @@ -0,0 +1,24 @@
> +#
> +# Copyright (c) 2013 LinkedIn Corp. All rights reserved. 
> +# Licensed 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.
> +#
> +
> +AM_CPPFLAGS = -I$(top_srcdir)/src/include
> +
> +target=intercept.so
> +pkglibdir = ${pkglibexecdir}
> +pkglib_LTLIBRARIES = intercept.la
> +intercept_la_SOURCES = intercept.cc
> +intercept_la_LDFLAGS = -module -avoid-version -shared -L$(top_srcdir) -latscppapi
> +
> +all:
> +	ln -sf .libs/$(target)
> +
> +clean-local:
> +	rm -f $(target)
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/examples/intercept/intercept.cc
> ----------------------------------------------------------------------
> diff --git a/lib/atscppapi/examples/intercept/intercept.cc b/lib/atscppapi/examples/intercept/intercept.cc
> new file mode 100644
> index 0000000..4c98782
> --- /dev/null
> +++ b/lib/atscppapi/examples/intercept/intercept.cc
> @@ -0,0 +1,55 @@
> +#include <atscppapi/GlobalPlugin.h>
> +#include <atscppapi/InterceptPlugin.h>
> +#include <atscppapi/PluginInit.h>
> +
> +#include <iostream>
> +
> +using namespace atscppapi;
> +using std::string;
> +using std::cout;
> +using std::endl;
> +
> +class Intercept : public InterceptPlugin {
> +public:
> +  Intercept(Transaction &transaction) : InterceptPlugin(transaction, InterceptPlugin::SERVER_INTERCEPT) { }
> +  void consume(const string &data, InterceptPlugin::RequestDataType type);
> +  void handleInputComplete();
> +  ~Intercept() { cout << "Shutting down" << endl; }
> +};
> +
> +class InterceptInstaller : public GlobalPlugin {
> +public:
> +  InterceptInstaller() : GlobalPlugin(true /* ignore internal transactions */) {
> +    GlobalPlugin::registerHook(Plugin::HOOK_READ_REQUEST_HEADERS_PRE_REMAP);
> +  }
> +  void handleReadRequestHeadersPreRemap(Transaction &transaction) {
> +    transaction.addPlugin(new Intercept(transaction));
> +    cout << "Added intercept" << endl;
> +    transaction.resume();
> +  }
> +};
> +
> +void TSPluginInit(int argc, const char *argv[]) {
> +  new InterceptInstaller();
> +}
> +
> +void Intercept::consume(const string &data, InterceptPlugin::RequestDataType type) {
> +  if (type == InterceptPlugin::REQUEST_HEADER) {
> +    cout << "Read request header data" << endl << data;
> +  }
> +  else {
> +    cout << "Read request body data" << endl << data << endl;
> +  }
> +}
> +
> +void Intercept::handleInputComplete() {
> +  cout << "Request data complete" << endl;
> +  string response("HTTP/1.1 200 OK\r\n"
> +                  "Content-Length: 7\r\n"
> +                  "\r\n");
> +  InterceptPlugin::produce(response);
> +//  sleep(5); TODO: this is a test for streaming; currently doesn't work
> +  response = "hello\r\n";
> +  InterceptPlugin::produce(response);
> +  InterceptPlugin::setOutputComplete();
> +}
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/src/Makefile.am
> ----------------------------------------------------------------------
> diff --git a/lib/atscppapi/src/Makefile.am b/lib/atscppapi/src/Makefile.am
> index 4e7d204..346bdee 100644
> --- a/lib/atscppapi/src/Makefile.am
> +++ b/lib/atscppapi/src/Makefile.am
> @@ -51,7 +51,8 @@ libatscppapi_la_SOURCES = GlobalPlugin.cc \
> 			  RemapPlugin.cc \
> 			  GzipDeflateTransformation.cc \
> 			  GzipInflateTransformation.cc \
> -			  AsyncTimer.cc
> +			  AsyncTimer.cc \
> +                          InterceptPlugin.cc
> 
> library_includedir=$(includedir)/atscppapi
> base_include_folder = include/atscppapi/
> @@ -82,4 +83,5 @@ library_include_HEADERS = $(base_include_folder)/GlobalPlugin.h \
> 			  $(base_include_folder)/AsyncHttpFetch.h \
> 			  $(base_include_folder)/GzipDeflateTransformation.h \
> 			  $(base_include_folder)/GzipInflateTransformation.h \
> -			  $(base_include_folder)/AsyncTimer.h
> +			  $(base_include_folder)/AsyncTimer.h \
> +			  $(base_include_folder)/InterceptPlugin.h
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/src/include/utils_internal.h
> ----------------------------------------------------------------------
> diff --git a/lib/atscppapi/src/include/utils_internal.h b/lib/atscppapi/src/include/utils_internal.h
> index 0eb499e..c6ead71 100644
> --- a/lib/atscppapi/src/include/utils_internal.h
> +++ b/lib/atscppapi/src/include/utils_internal.h
> @@ -37,6 +37,7 @@
> #include "atscppapi/utils.h"
> #include "atscppapi/AsyncHttpFetch.h"
> #include "atscppapi/Transaction.h"
> +#include "atscppapi/InterceptPlugin.h"
> 
> namespace atscppapi {
> 
> @@ -80,6 +81,11 @@ public:
>   static const std::list<TransactionPlugin *> &getTransactionPlugins(const Transaction &transaction) {
>     return transaction.getPlugins();
>   }
> +
> +  static void dispatchInterceptEvent(InterceptPlugin *plugin, TSEvent event, void *edata) {
> +    plugin->handleEvent(static_cast<int>(event), edata);
> +  }
> +
> }; /* internal */
> 
> } /* utils */
> 


Re: [2/2] git commit: intercept support in atscppapi

Posted by James Peach <jp...@apache.org>.
We should have a JIRA ticket for this so that we can publish accurate change logs and release notes


On Mar 6, 2014, at 12:47 PM, briang@apache.org wrote:

> intercept support in atscppapi
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/b4c34003
> Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/b4c34003
> Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/b4c34003
> 
> Branch: refs/heads/master
> Commit: b4c34003301694dc5a26498382c4446364d4a2eb
> Parents: 79ae4a1
> Author: Manjesh Nilange <ma...@yahoo.com>
> Authored: Thu Mar 6 12:36:54 2014 -0800
> Committer: Manjesh Nilange <ma...@yahoo.com>
> Committed: Thu Mar 6 12:36:54 2014 -0800
> 
> ----------------------------------------------------------------------
> configure.ac                                  |  1 +
> lib/atscppapi/examples/Makefile.am            |  3 +-
> lib/atscppapi/examples/intercept/Makefile.am  | 24 ++++++++++
> lib/atscppapi/examples/intercept/intercept.cc | 55 ++++++++++++++++++++++
> lib/atscppapi/src/Makefile.am                 |  6 ++-
> lib/atscppapi/src/include/utils_internal.h    |  6 +++
> 6 files changed, 92 insertions(+), 3 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/configure.ac
> ----------------------------------------------------------------------
> diff --git a/configure.ac b/configure.ac
> index 875f2c4..7460f7c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1937,6 +1937,7 @@ AC_CONFIG_FILES([
>   lib/atscppapi/examples/timeout_example/Makefile
>   lib/atscppapi/examples/internal_transaction_handling/Makefile
>   lib/atscppapi/examples/async_timer/Makefile
> +  lib/atscppapi/examples/intercept/Makefile
>   lib/wccp/Makefile
>   lib/perl/Makefile
>   lib/perl/lib/Apache/TS.pm
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/examples/Makefile.am
> ----------------------------------------------------------------------
> diff --git a/lib/atscppapi/examples/Makefile.am b/lib/atscppapi/examples/Makefile.am
> index 23c9c70..9cbf7d6 100644
> --- a/lib/atscppapi/examples/Makefile.am
> +++ b/lib/atscppapi/examples/Makefile.am
> @@ -33,4 +33,5 @@ SUBDIRS = helloworld \
> 	  gzip_transformation \
> 	  timeout_example \
>       internal_transaction_handling \
> -      async_timer
> \ No newline at end of file
> +      async_timer \
> +      intercept
> \ No newline at end of file
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/examples/intercept/Makefile.am
> ----------------------------------------------------------------------
> diff --git a/lib/atscppapi/examples/intercept/Makefile.am b/lib/atscppapi/examples/intercept/Makefile.am
> new file mode 100644
> index 0000000..2400a10
> --- /dev/null
> +++ b/lib/atscppapi/examples/intercept/Makefile.am
> @@ -0,0 +1,24 @@
> +#
> +# Copyright (c) 2013 LinkedIn Corp. All rights reserved. 
> +# Licensed 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.
> +#
> +
> +AM_CPPFLAGS = -I$(top_srcdir)/src/include
> +
> +target=intercept.so
> +pkglibdir = ${pkglibexecdir}
> +pkglib_LTLIBRARIES = intercept.la
> +intercept_la_SOURCES = intercept.cc
> +intercept_la_LDFLAGS = -module -avoid-version -shared -L$(top_srcdir) -latscppapi
> +
> +all:
> +	ln -sf .libs/$(target)
> +
> +clean-local:
> +	rm -f $(target)
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/examples/intercept/intercept.cc
> ----------------------------------------------------------------------
> diff --git a/lib/atscppapi/examples/intercept/intercept.cc b/lib/atscppapi/examples/intercept/intercept.cc
> new file mode 100644
> index 0000000..4c98782
> --- /dev/null
> +++ b/lib/atscppapi/examples/intercept/intercept.cc
> @@ -0,0 +1,55 @@
> +#include <atscppapi/GlobalPlugin.h>
> +#include <atscppapi/InterceptPlugin.h>
> +#include <atscppapi/PluginInit.h>
> +
> +#include <iostream>
> +
> +using namespace atscppapi;
> +using std::string;
> +using std::cout;
> +using std::endl;
> +
> +class Intercept : public InterceptPlugin {
> +public:
> +  Intercept(Transaction &transaction) : InterceptPlugin(transaction, InterceptPlugin::SERVER_INTERCEPT) { }
> +  void consume(const string &data, InterceptPlugin::RequestDataType type);
> +  void handleInputComplete();
> +  ~Intercept() { cout << "Shutting down" << endl; }
> +};
> +
> +class InterceptInstaller : public GlobalPlugin {
> +public:
> +  InterceptInstaller() : GlobalPlugin(true /* ignore internal transactions */) {
> +    GlobalPlugin::registerHook(Plugin::HOOK_READ_REQUEST_HEADERS_PRE_REMAP);
> +  }
> +  void handleReadRequestHeadersPreRemap(Transaction &transaction) {
> +    transaction.addPlugin(new Intercept(transaction));
> +    cout << "Added intercept" << endl;
> +    transaction.resume();
> +  }
> +};
> +
> +void TSPluginInit(int argc, const char *argv[]) {
> +  new InterceptInstaller();
> +}
> +
> +void Intercept::consume(const string &data, InterceptPlugin::RequestDataType type) {
> +  if (type == InterceptPlugin::REQUEST_HEADER) {
> +    cout << "Read request header data" << endl << data;
> +  }
> +  else {
> +    cout << "Read request body data" << endl << data << endl;
> +  }
> +}
> +
> +void Intercept::handleInputComplete() {
> +  cout << "Request data complete" << endl;
> +  string response("HTTP/1.1 200 OK\r\n"
> +                  "Content-Length: 7\r\n"
> +                  "\r\n");
> +  InterceptPlugin::produce(response);
> +//  sleep(5); TODO: this is a test for streaming; currently doesn't work
> +  response = "hello\r\n";
> +  InterceptPlugin::produce(response);
> +  InterceptPlugin::setOutputComplete();
> +}
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/src/Makefile.am
> ----------------------------------------------------------------------
> diff --git a/lib/atscppapi/src/Makefile.am b/lib/atscppapi/src/Makefile.am
> index 4e7d204..346bdee 100644
> --- a/lib/atscppapi/src/Makefile.am
> +++ b/lib/atscppapi/src/Makefile.am
> @@ -51,7 +51,8 @@ libatscppapi_la_SOURCES = GlobalPlugin.cc \
> 			  RemapPlugin.cc \
> 			  GzipDeflateTransformation.cc \
> 			  GzipInflateTransformation.cc \
> -			  AsyncTimer.cc
> +			  AsyncTimer.cc \
> +                          InterceptPlugin.cc
> 
> library_includedir=$(includedir)/atscppapi
> base_include_folder = include/atscppapi/
> @@ -82,4 +83,5 @@ library_include_HEADERS = $(base_include_folder)/GlobalPlugin.h \
> 			  $(base_include_folder)/AsyncHttpFetch.h \
> 			  $(base_include_folder)/GzipDeflateTransformation.h \
> 			  $(base_include_folder)/GzipInflateTransformation.h \
> -			  $(base_include_folder)/AsyncTimer.h
> +			  $(base_include_folder)/AsyncTimer.h \
> +			  $(base_include_folder)/InterceptPlugin.h
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b4c34003/lib/atscppapi/src/include/utils_internal.h
> ----------------------------------------------------------------------
> diff --git a/lib/atscppapi/src/include/utils_internal.h b/lib/atscppapi/src/include/utils_internal.h
> index 0eb499e..c6ead71 100644
> --- a/lib/atscppapi/src/include/utils_internal.h
> +++ b/lib/atscppapi/src/include/utils_internal.h
> @@ -37,6 +37,7 @@
> #include "atscppapi/utils.h"
> #include "atscppapi/AsyncHttpFetch.h"
> #include "atscppapi/Transaction.h"
> +#include "atscppapi/InterceptPlugin.h"
> 
> namespace atscppapi {
> 
> @@ -80,6 +81,11 @@ public:
>   static const std::list<TransactionPlugin *> &getTransactionPlugins(const Transaction &transaction) {
>     return transaction.getPlugins();
>   }
> +
> +  static void dispatchInterceptEvent(InterceptPlugin *plugin, TSEvent event, void *edata) {
> +    plugin->handleEvent(static_cast<int>(event), edata);
> +  }
> +
> }; /* internal */
> 
> } /* utils */
>