You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2014/09/29 18:16:14 UTC
git commit: C++ API enhancement - redirect support.
Repository: trafficserver
Updated Branches:
refs/heads/master b16c20879 -> 8c985ee41
C++ API enhancement - redirect support.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/8c985ee4
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/8c985ee4
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/8c985ee4
Branch: refs/heads/master
Commit: 8c985ee41994013b8ba106edf30dfe6ee30de975
Parents: b16c208
Author: Alan M. Carroll <am...@network-geographics.com>
Authored: Mon Sep 29 11:15:09 2014 -0500
Committer: Alan M. Carroll <am...@network-geographics.com>
Committed: Mon Sep 29 11:16:00 2014 -0500
----------------------------------------------------------------------
lib/atscppapi/src/Transaction.cc | 13 ++++++++++---
lib/atscppapi/src/include/atscppapi/Transaction.h | 5 +++++
2 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8c985ee4/lib/atscppapi/src/Transaction.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/Transaction.cc b/lib/atscppapi/src/Transaction.cc
index 2470e7f..52f3dfe 100644
--- a/lib/atscppapi/src/Transaction.cc
+++ b/lib/atscppapi/src/Transaction.cc
@@ -26,6 +26,7 @@
#include <map>
#include <string>
#include <ts/ts.h>
+#include <ink_memory.h>
#include "atscppapi/shared_ptr.h"
#include "logging_internal.h"
#include "utils_internal.h"
@@ -178,8 +179,8 @@ string Transaction::getEffectiveUrl() {
}
bool Transaction::setCacheUrl(const string &cache_url) {
- TSReturnCode res = TSCacheUrlSet(state_->txn_, cache_url.c_str(), cache_url.length());
- return (res == TS_SUCCESS);
+ TSReturnCode res = TSCacheUrlSet(state_->txn_, cache_url.c_str(), cache_url.length());
+ return (res == TS_SUCCESS);
}
const sockaddr *Transaction::getIncomingAddress() const {
@@ -248,10 +249,16 @@ void Transaction::setTimeout(Transaction::TimeoutType type, int time_ms) {
}
}
+void Transaction::redirectTo(std::string const& url) {
+ char* s = ats_strdup(url.c_str());
+ // Must re-alloc the string locally because ownership is transferred to the transaction.
+ TSHttpTxnRedirectUrlSet(state_->txn_, s, url.length());
+}
+
namespace {
/**
- * initializeHandles is a convinience functor that takes a pointer to a TS Function that
+ * initializeHandles is a convenience functor that takes a pointer to a TS Function that
* will return the TSMBuffer and TSMLoc for a given server request/response or client/request response
*
* @param constructor takes a function pointer of type GetterFunction
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8c985ee4/lib/atscppapi/src/include/atscppapi/Transaction.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Transaction.h b/lib/atscppapi/src/include/atscppapi/Transaction.h
index 1e6014f..dbf18b8 100644
--- a/lib/atscppapi/src/include/atscppapi/Transaction.h
+++ b/lib/atscppapi/src/include/atscppapi/Transaction.h
@@ -298,6 +298,11 @@ public:
* @return client response header size */
size_t getClientResponseHeaderSize();
+ /**
+ * Redirect the transaction a different @a url.
+ */
+ void redirectTo(std::string const& url);
+
private:
TransactionState *state_; //!< The internal TransactionState object tied to the current Transaction
friend class TransactionPlugin; //!< TransactionPlugin is a friend so it can call addPlugin()