trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [trafficserver] branch master updated: Add SINK_TRANSFORM option to CPPAPI
Date Wed, 03 May 2017 01:31:31 GMT
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  6ea1f4c   Add SINK_TRANSFORM option to CPPAPI
6ea1f4c is described below

commit 6ea1f4ca10ef90a0f0b1db78d21f60767cc33a9a
Author: Daniel Xu <dxu@dxuuu.xyz>
AuthorDate: Fri Apr 21 11:25:27 2017 -0500

    Add SINK_TRANSFORM option to CPPAPI
    
    This adds support for the TS_HTTP_RESPONSE_CLIENT_HOOK into the CPPAPI
    TransformationPlugin. TS_HTTP_RESPONSE_CLIENT_HOOK is a unique
    transformation hook in that there is an input channel but no output
    channel.
---
 lib/cppapi/TransformationPlugin.cc                  | 12 +++++++++++-
 lib/cppapi/include/atscppapi/TransformationPlugin.h |  4 +++-
 lib/cppapi/utils_internal.cc                        |  2 ++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/lib/cppapi/TransformationPlugin.cc b/lib/cppapi/TransformationPlugin.cc
index 20e7821..7fc502d 100644
--- a/lib/cppapi/TransformationPlugin.cc
+++ b/lib/cppapi/TransformationPlugin.cc
@@ -321,6 +321,10 @@ TransformationPlugin::produce(const std::string &data)
   if (state_->type_ == REQUEST_TRANSFORMATION) {
     state_->request_xform_output_.append(data);
     return data.size();
+  } else if (state_->type_ == SINK_TRANSFORMATION) {
+    LOG_DEBUG("produce TransformationPlugin=%p tshttptxn=%p : This is a sink transform. Not
producing any output", this,
+              state_->txn_);
+    return 0;
   } else {
     return doProduce(data);
   }
@@ -329,7 +333,13 @@ TransformationPlugin::produce(const std::string &data)
 size_t
 TransformationPlugin::setOutputComplete()
 {
-  if (state_->type_ == REQUEST_TRANSFORMATION) {
+  if (state_->type_ == SINK_TRANSFORMATION) {
+    // There's no output stream for a sink transform, so we do nothing
+    //
+    // Warning: don't try to shutdown the VConn, since the default implementation (DummyVConnection)
+    // has a stubbed out shutdown/close implementation
+    return 0;
+  } else if (state_->type_ == REQUEST_TRANSFORMATION) {
     doProduce(state_->request_xform_output_);
   }
 
diff --git a/lib/cppapi/include/atscppapi/TransformationPlugin.h b/lib/cppapi/include/atscppapi/TransformationPlugin.h
index e969832..8073375 100644
--- a/lib/cppapi/include/atscppapi/TransformationPlugin.h
+++ b/lib/cppapi/include/atscppapi/TransformationPlugin.h
@@ -86,7 +86,9 @@ public:
    */
   enum Type {
     REQUEST_TRANSFORMATION = 0, /**< Transform the Request body content */
-    RESPONSE_TRANSFORMATION     /**< Transform the Response body content */
+    RESPONSE_TRANSFORMATION,    /**< Transform the Response body content */
+    SINK_TRANSFORMATION         /**< Sink transformation, meaning you get a separate stream
of the Response
+                                     body content that does not get hooked up to a downstream
input */
   };
 
   /**
diff --git a/lib/cppapi/utils_internal.cc b/lib/cppapi/utils_internal.cc
index f930303..a70ca25 100644
--- a/lib/cppapi/utils_internal.cc
+++ b/lib/cppapi/utils_internal.cc
@@ -210,6 +210,8 @@ utils::internal::convertInternalTransformationTypeToTsHook(TransformationPlugin:
     return TS_HTTP_RESPONSE_TRANSFORM_HOOK;
   case TransformationPlugin::REQUEST_TRANSFORMATION:
     return TS_HTTP_REQUEST_TRANSFORM_HOOK;
+  case TransformationPlugin::SINK_TRANSFORMATION:
+    return TS_HTTP_RESPONSE_CLIENT_HOOK;
   default:
     assert(false); // shouldn't happen, let's catch it early
     break;

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Mime
View raw message