trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject [2/2] git commit: more changes to c++11 api, header code on the way
Date Mon, 03 Sep 2012 04:34:47 GMT
more changes to c++11 api, header code on the way


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

Branch: refs/heads/master
Commit: a1b4019d610f1e8ed60c33a1cd4563a55da43088
Parents: dab051d
Author: Brian Geffon <briang@apache.org>
Authored: Sun Sep 2 21:31:54 2012 -0700
Committer: Brian Geffon <briang@apache.org>
Committed: Sun Sep 2 21:31:54 2012 -0700

----------------------------------------------------------------------
 lib/cpp11api/cpp11api.cc        |   18 +++++--
 lib/cpp11api/ts-cpp11-headers.h |   90 ++++++++++++++++++++++++++++++++++
 lib/cpp11api/ts-cpp11.h         |   19 +++++--
 3 files changed, 118 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a1b4019d/lib/cpp11api/cpp11api.cc
----------------------------------------------------------------------
diff --git a/lib/cpp11api/cpp11api.cc b/lib/cpp11api/cpp11api.cc
index 605902b..0294834 100644
--- a/lib/cpp11api/cpp11api.cc
+++ b/lib/cpp11api/cpp11api.cc
@@ -73,18 +73,24 @@ TSHttpHookID TSHookIDFromHookType(HookType hook) {
   case ats::api::HookType::HOOK_POST_REMAP:
     return TS_HTTP_POST_REMAP_HOOK;
     break;
-  case ats::api::HookType::HOOK_READ_REQUEST_HEADER:
+  case ats::api::HookType::HOOK_READ_REQUEST_HEADERS:
     return TS_HTTP_READ_REQUEST_HDR_HOOK;
     break;
-  case ats::api::HookType::HOOK_READ_RESPONSE_HEADER:
+  case ats::api::HookType::HOOK_READ_RESPONSE_HEADERS:
     return TS_HTTP_READ_RESPONSE_HDR_HOOK;
     break;
-  case ats::api::HookType::HOOK_SEND_RESPONSE_HEADER:
+  case ats::api::HookType::HOOK_SEND_RESPONSE_HEADERS:
     return TS_HTTP_SEND_RESPONSE_HDR_HOOK;
     break;
+  case ats::api::HookType::HOOK_TRANSACTION_START:
+    return TS_HTTP_TXN_START_HOOK;
+    break;
+  case ats::api::HookType::HOOK_TRANSACTION_END:
+    return TS_HTTP_TXN_CLOSE_HOOK;
+    break;
   }
 
-  return TS_HTTP_READ_REQUEST_HDR_HOOK;
+  return NULL;
 }
 
 void inline ReenableBasedOnNextState(TSHttpTxn txnp, NextState ns) {
@@ -511,6 +517,10 @@ static int TransactionContinuationHandler(TSCont contp, TSEvent event,
   return 0;
 }
 
+void* ats::api::GetTransactionIdentifier(Transaction &t) {
+  return reinterpret_cast<void *>(t.ts_http_txn_);
+}
+
 void ats::api::CreateTransactionHook(Transaction &txn, HookType hook,
     GlobalHookCallback callback) {
   TSHttpHookID ts_hook_id = TSHookIDFromHookType(hook);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a1b4019d/lib/cpp11api/ts-cpp11-headers.h
----------------------------------------------------------------------
diff --git a/lib/cpp11api/ts-cpp11-headers.h b/lib/cpp11api/ts-cpp11-headers.h
new file mode 100644
index 0000000..fbc991f
--- /dev/null
+++ b/lib/cpp11api/ts-cpp11-headers.h
@@ -0,0 +1,90 @@
+/*
+ * ts-cpp11-headers.h
+ *
+ *  Created on: Sep 2, 2012
+ *      Author: bgeffon
+ */
+
+#ifndef TS_CPP11_HEADERS_H_
+#define TS_CPP11_HEADERS_H_
+#include <functional>
+#include <string>
+#include <vector>
+#include <memory>
+
+namespace ats {
+namespace api {
+namespace headers {
+
+class Header;
+typedef std::vector<Header> HeaderVector;
+
+class Header {
+private:
+  std::string name_;
+  std::vector<std::string> field_values_;
+public:
+  Header() {
+  }
+  Header(const std::string &name, const std::string &value) {
+    name_ = name;
+    addNewValue(value);
+  }
+
+  Header(std::string name, const std::vector<std::string> & values) {
+    name_ = name;
+    field_values_ = values;
+  }
+
+  void assignName(const std::string & name) {
+    name_ = name;
+  }
+
+  void assignName(const char *buf, size_t len) {
+    name_.assign(buf, len);
+  }
+
+  void addNewValue(const char *buf, size_t len) {
+    std::string newVal(buf, len);
+    field_values_.push_back(newVal);
+  }
+
+  void addNewValue(std::string value) {
+    field_values_.push_back(value);
+  }
+
+  int getNumValues() {
+    return field_values_.size();
+  }
+
+  std::string getValue(int valueindx) {
+    return field_values_[valueindx];
+  }
+
+  std::string getName() {
+    return name_;
+  }
+
+  std::string getJoinedValues() {
+    std::string ret;
+
+    for (std::vector<std::string>::size_type i = 0; i < field_values_.size();
+        ++i) {
+      if (i > 0)
+        ret.append(",");
+      ret.append(field_values_[i]);
+    }
+    return ret;
+  }
+
+  std::vector<std::string> getValues() {
+    return field_values_;
+  }
+};
+
+
+}
+}
+}
+
+#endif /* TS_CPP11_HEADERS_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a1b4019d/lib/cpp11api/ts-cpp11.h
----------------------------------------------------------------------
diff --git a/lib/cpp11api/ts-cpp11.h b/lib/cpp11api/ts-cpp11.h
index 853df44..8743034 100644
--- a/lib/cpp11api/ts-cpp11.h
+++ b/lib/cpp11api/ts-cpp11.h
@@ -36,9 +36,11 @@ typedef std::vector<std::string> StringVector;
 enum class HookType {
   HOOK_PRE_REMAP = 100,
   HOOK_POST_REMAP,
-  HOOK_READ_RESPONSE_HEADER,
-  HOOK_READ_REQUEST_HEADER,
-  HOOK_SEND_RESPONSE_HEADER
+  HOOK_READ_RESPONSE_HEADERS,
+  HOOK_READ_REQUEST_HEADERS,
+  HOOK_SEND_RESPONSE_HEADERS,
+  HOOK_TRANSACTION_START,
+  HOOK_TRANSACTION_END
 };
 
 enum class NextState {
@@ -83,9 +85,16 @@ std::string GetRequestMethod(Transaction &t);
 void SetRequestMethod(Transaction &t, const std::string &);
 int GetServerResponseStatusCode(Transaction &t);
 bool IsInternalRequest(Transaction &);
+void* GetTransactionIdentifier(Transaction &);
 
-}
-}
+
+/* headers */
+namespace headers {
+// header code coming very soon
+} /* headers */
+
+} /* api */
+} /* ats */
 
 /*
  * Every plugin must have a simple entry point


Mime
View raw message