Patch for TS-2667 atscppapi: Allow intercept plugins to access request headers object
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/5994228b Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/5994228b Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/5994228b Branch: refs/heads/master Commit: 5994228bdab3fa704eb74fc5e26896166254ca88 Parents: 521b6e1 Author: Manjesh Nilange <[email protected]> Authored: Wed Mar 26 17:21:46 2014 -0700 Committer: Manjesh Nilange <[email protected]> Committed: Wed Mar 26 17:21:46 2014 -0700 ---------------------------------------------------------------------- lib/atscppapi/src/InterceptPlugin.cc | 6 ++++++ lib/atscppapi/src/include/atscppapi/InterceptPlugin.h | 3 +++ 2 files changed, 9 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5994228b/lib/atscppapi/src/InterceptPlugin.cc ---------------------------------------------------------------------- diff --git a/lib/atscppapi/src/InterceptPlugin.cc b/lib/atscppapi/src/InterceptPlugin.cc index c06e494..b9aaa7c 100644 --- a/lib/atscppapi/src/InterceptPlugin.cc +++ b/lib/atscppapi/src/InterceptPlugin.cc @@ -85,6 +85,7 @@ struct InterceptPlugin::State { int num_bytes_written_; PluginHandle *plugin_handle_; bool shut_down_; + Headers request_headers_; State(TSCont cont) : cont_(cont), net_vc_(NULL), expected_body_size_(0), num_body_bytes_read_(0), hdr_parsed_(false), hdr_buf_(NULL), hdr_loc_(NULL), num_bytes_written_(0), @@ -197,6 +198,10 @@ bool InterceptPlugin::setOutputComplete() { return true; } +Headers &InterceptPlugin::getRequestHeaders() { + return state_->request_headers_; +} + bool InterceptPlugin::doRead() { int avail = TSIOBufferReaderAvail(state_->input_.reader_); if (avail == TS_ERROR) { @@ -273,6 +278,7 @@ void InterceptPlugin::handleEvent(int abstract_event, void *edata) { state_->hdr_buf_ = TSMBufferCreate(); state_->hdr_loc_ = TSHttpHdrCreate(state_->hdr_buf_); + state_->request_headers_.reset(state_->hdr_buf_, state_->hdr_loc_); TSHttpHdrTypeSet(state_->hdr_buf_, state_->hdr_loc_, TS_HTTP_TYPE_REQUEST); break; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5994228b/lib/atscppapi/src/include/atscppapi/InterceptPlugin.h ---------------------------------------------------------------------- diff --git a/lib/atscppapi/src/include/atscppapi/InterceptPlugin.h b/lib/atscppapi/src/include/atscppapi/InterceptPlugin.h index 5160c8d..da8d5a4 100644 --- a/lib/atscppapi/src/include/atscppapi/InterceptPlugin.h +++ b/lib/atscppapi/src/include/atscppapi/InterceptPlugin.h @@ -68,6 +68,9 @@ public: */ virtual void handleInputComplete() = 0; + /** Should be called only after request header has completely been consumed */ + Headers &getRequestHeaders(); + virtual ~InterceptPlugin(); struct State; /** Internal use only */
