You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2013/10/27 22:36:39 UTC

[14/50] [abbrv] initial atscppapi commit

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/ClientRequest.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/ClientRequest.h b/lib/atscppapi/src/include/atscppapi/ClientRequest.h
new file mode 100644
index 0000000..2da61c5
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/ClientRequest.h
@@ -0,0 +1,59 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/**
+ * @file ClientRequest.h
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_CLIENTREQUEST_H_
+#define ATSCPPAPI_CLIENTREQUEST_H_
+
+#include <atscppapi/Request.h>
+
+namespace atscppapi {
+
+struct ClientRequestState;
+
+/**
+ * @brief Encapsulates a client request. A client request is different from a
+ * server request as it has two URLs - the pristine URL sent by the client 
+ * and a remapped URL created by the server.
+ */
+class ClientRequest : public Request {
+public:
+  /**
+   * @private
+   */
+  ClientRequest(void *raw_txn, void *hdr_buf, void *hdr_loc);
+
+  /**
+   * Returns the pristine (pre-remap) client request URL 
+   *
+   * @return Url Reference to non-mutable pristine URL.
+   */
+  const Url &getPristineUrl() const;
+
+  ~ClientRequest();
+private:
+  ClientRequestState *state_;
+};
+
+}
+
+#endif /* ATSCPPAPI_CLIENTREQUEST_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/GlobalPlugin.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/GlobalPlugin.h b/lib/atscppapi/src/include/atscppapi/GlobalPlugin.h
new file mode 100644
index 0000000..cff431d
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/GlobalPlugin.h
@@ -0,0 +1,90 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/**
+ * @file GlobalPlugin.h
+ * @brief Contains the interface used in creating Global plugins.
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_GLOBALPLUGIN_H_
+#define ATSCPPAPI_GLOBALPLUGIN_H_
+
+#include <atscppapi/Plugin.h>
+
+namespace atscppapi {
+
+class GlobalPluginState;
+
+/**
+ * @brief The interface used when creating a GlobalPlugin.
+ *
+ * A GlobalPlugin is a Plugin that will fire for a given hook on all Transactions.
+ * In otherwords, a GlobalPlugin is not tied to a specific plugin, a Transaction
+ * specific plugin would be a TransactionPlugin.
+ *
+ * Depending on the
+ * type of hook you choose to build you will implement one or more callback methods.
+ * Here is a simple example of a GlobalPlugin:
+ *
+ * \code
+ * class GlobalHookPlugin : public GlobalPlugin {
+ * public:
+ *  GlobalHookPlugin() {
+ *   registerHook(HOOK_READ_REQUEST_HEADERS_PRE_REMAP);
+ *  }
+ *  virtual void handleReadRequestHeadersPreRemap(Transaction &transaction) {
+ *    std::cout << "Hello from handleReadRequesHeadersPreRemap!" << std::endl;
+ *    transaction.resume();
+ *  }
+ * };
+ * \endcode
+ * @see Plugin
+ */
+class GlobalPlugin : public Plugin {
+public:
+  /**
+   * registerHook is the mechanism used to attach a global hook.
+   *
+   * \note Whenever you register a hook you must have the appropriate callback definied in your GlobalPlugin
+   *  see HookType and Plugin for the correspond HookTypes and callback methods. If you fail to implement the
+   *  callback, a default implmentation will be used that will only resume the Transaction.
+   *
+   * @param HookType the type of hook you wish to register
+   * @see HookType
+   * @see Plugin
+   */
+  void registerHook(Plugin::HookType);
+  virtual ~GlobalPlugin();
+protected:
+  /**
+   * Constructor.
+   *
+   * @param ignore_internal_transactions When true, all hooks registered by this plugin are ignored
+   *                                     for internal transactions (internal transactions are created
+   *                                     when other plugins create requests). Defaults to false.
+   */
+  GlobalPlugin(bool ignore_internal_transactions = false);
+private:
+  GlobalPluginState *state_; /**< Internal state tied to a GlobalPlugin */
+};
+
+} /* atscppapi */
+
+
+#endif /* ATSCPPAPI_GLOBALPLUGIN_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/GzipDeflateTransformation.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/GzipDeflateTransformation.h b/lib/atscppapi/src/include/atscppapi/GzipDeflateTransformation.h
new file mode 100644
index 0000000..a7e6923
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/GzipDeflateTransformation.h
@@ -0,0 +1,91 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/**
+ * @file GzipDeflateTransformation.h
+ * @brief Gzip Deflate Transformation can be used to compress content.
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_GZIPDEFLATETRANSFORMATION_H_
+#define ATSCPPAPI_GZIPDEFLATETRANSFORMATION_H_
+
+#include <string>
+#include "atscppapi/TransformationPlugin.h"
+
+namespace atscppapi {
+
+namespace transformations {
+
+/**
+ * Internal state for Deflate Transformations
+ * @private
+ */
+class GzipDeflateTransformationState;
+
+/**
+ * @brief A TransformationPlugin to easily add gzip deflate to your TransformationPlugin chain.
+ *
+ * The GzipDeflateTransformation is a helper transformation that can be used
+ * to easily compress content. For a full example of GzipDeflateTransformation
+ * and GzipInflateTransformation see examples/gzip_transformation/.
+ *
+ * @note GzipDeflateTransformation DOES NOT set Content-Encoding headers, it is the
+ * users responsibility to set any applicable headers.
+ *
+ * @see GzipInflateTransformation
+ */
+class GzipDeflateTransformation : public TransformationPlugin {
+public:
+  /**
+   * A full example of how to use GzipDeflateTransformation and GzipInflateTransformation is available
+   * in examples/gzip_tranformation/
+   *
+   * @param transaction As with any TransformationPlugin you must pass in the transaction
+   * @param type because the GzipDeflateTransformation can be used with both requests and responses
+   *  you must specify the Type.
+   *
+   * @see TransformationPlugin::Type
+   */
+  GzipDeflateTransformation(Transaction &transaction, TransformationPlugin::Type type);
+
+  /**
+   * Any TransformationPlugin must implement consume(), this method will take content
+   * from the transformation chain and gzip compress it.
+   *
+   * @param data the input data to compress
+   */
+  void consume(const std::string &data);
+
+  /**
+   * Any TransformationPlugin must implement handleInputComplete(), this method will
+   * finalize the gzip compression and flush any remaining data and the epilouge.
+   */
+  void handleInputComplete();
+
+  virtual ~GzipDeflateTransformation();
+private:
+  GzipDeflateTransformationState *state_; /** Internal state for Gzip Deflate Transformations */
+};
+
+}
+
+}
+
+
+#endif /* ATSCPPAPI_GZIPDEFLATETRANSFORMATION_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/GzipInflateTransformation.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/GzipInflateTransformation.h b/lib/atscppapi/src/include/atscppapi/GzipInflateTransformation.h
new file mode 100644
index 0000000..412af91
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/GzipInflateTransformation.h
@@ -0,0 +1,92 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/**
+ * @file GzipInflateTransformation.h
+ * @brief Gzip Inflate Transformation can be used to decompress gzipped content.
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_GZIPINFLATETRANSFORMATION_H_
+#define ATSCPPAPI_GZIPINFLATETRANSFORMATION_H_
+
+#include <string>
+#include "atscppapi/TransformationPlugin.h"
+
+namespace atscppapi {
+
+namespace transformations {
+
+/**
+ * Internal state for Inflate Transformations
+ * @private
+ */
+class GzipInflateTransformationState;
+
+/**
+ * @brief A TransformationPlugin to easily add gzip inflate to your TransformationPlugin chain.
+ *
+ * The GzipInflateTransformation is a helper transformation that can be used
+ * to easily decompress gzipped content. For a full example of GzipInflateTransformation
+ * and GzipDeflateTransformation see examples/gzip_transformation/.
+ *
+ * @note GzipDeflateTransformation DOES NOT set or check Content-Encoding headers, it is the
+ * users responsibility to set any applicable headers and check that the content is acctually
+ * gzipped by checking the Content-Encoding header before creating a GzipInflateTransformation,
+ * see examples/gzip_transformation/ for a full example.
+ *
+ * @see GzipDeflateTransformation
+ */
+class GzipInflateTransformation : public TransformationPlugin {
+public:
+  /**
+   * A full example of how to use GzipInflateTransformation and GzipDeflateTransformation is available
+   * in examples/gzip_tranformation/
+   *
+   * @param transaction As with any TransformationPlugin you must pass in the transaction
+   * @param type because the GzipInflateTransformation can be used with both requests and responses
+   *  you must specify the Type.
+   *
+   * @see TransformationPlugin::Type
+   */
+  GzipInflateTransformation(Transaction &transaction, TransformationPlugin::Type type);
+
+  /**
+   * Any TransformationPlugin must implement consume(), this method will take content
+   * from the transformation chain and gzip decompress it.
+   *
+   * @param data the input data to decompress
+   */
+  void consume(const std::string &);
+
+  /**
+   * Any TransformationPlugin must implement handleInputComplete(), this method will
+   * finalize the gzip decompression.
+   */
+  void handleInputComplete();
+
+  virtual ~GzipInflateTransformation();
+private:
+  GzipInflateTransformationState *state_; /** Internal state for Gzip Deflate Transformations */
+};
+
+} /* transformations */
+
+} /* atscppapi */
+
+#endif /* ATSCPPAPI_GZIPINFLATETRANSFORMATION_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/Headers.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Headers.h b/lib/atscppapi/src/include/atscppapi/Headers.h
new file mode 100644
index 0000000..af02707
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/Headers.h
@@ -0,0 +1,246 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/**
+ * @file Headers.h
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_HEADERS_H_
+#define ATSCPPAPI_HEADERS_H_
+
+#include <map>
+#include <list>
+#include <atscppapi/CaseInsensitiveStringComparator.h>
+#include <atscppapi/noncopyable.h>
+
+namespace atscppapi {
+
+struct HeadersState;
+class Request;
+class ClientRequest;
+class Response;
+
+/**
+ * @brief Encapsulates the headers portion of a request or response.
+ */
+class Headers: noncopyable {
+public:
+  
+  enum Type { TYPE_REQUEST, TYPE_RESPONSE };
+
+  Headers(Type type = TYPE_REQUEST);
+
+  Type getType() const;
+
+  typedef std::map<std::string, std::list<std::string>, CaseInsensitiveStringComparator> NameValuesMap;
+
+  typedef NameValuesMap::size_type size_type;
+  typedef NameValuesMap::const_iterator const_iterator;
+  typedef NameValuesMap::const_reverse_iterator const_reverse_iterator;
+
+  /**
+   * @return Iterator to first header.
+   */
+  const_iterator begin() const;
+
+  /**
+   * @return Iterator to end of headers.
+   */
+  const_iterator end() const;
+
+  /**
+   * @return Iterator to last header.
+   */
+  const_reverse_iterator rbegin() const;
+
+  /**
+   * @return Iterator to "reverse end"
+   */
+  const_reverse_iterator rend() const;
+
+  /**
+   * @param key Name of header
+   * @return Iterator to header if exists, else end()
+   */
+  const_iterator find(const std::string &key) const;
+
+  /**
+   * @param key Name of header
+   * @return 1 if header exists, 0 if not. 
+   */
+  size_type count(const std::string &key) const;
+
+  /**
+   * Erases header with given name.
+   *
+   * @param key Name of header
+   * @return 1 if header was erased, 0 if not. 
+   */
+  size_type erase(const std::string &key);
+
+  /**
+   * Sets the given header and values. If a header of same name existed, that is
+   * deleted. Else header is appended.
+   * 
+   * @param pair Contains the name and list of values.
+   *
+   * @return Iterator to header set. 
+   */
+  const_iterator set(const std::pair<std::string, std::list<std::string> > &pair);
+
+  /**
+   * Sets the given header and values. If a header of same name existed, that is
+   * deleted. Else header is appended.
+   *
+   * @param key Name of header
+   * @param val List of values
+   * 
+   * @return Iterator to header set. 
+   */
+  const_iterator set(const std::string &key, const std::list<std::string> &val);
+
+  /**
+   * Sets the given header and values. If a header of same name existed, that is
+   * deleted. Else header is appended.
+   *
+   * @param key Name of header
+   * @param val Value
+   * 
+   * @return Iterator to header set. 
+   */
+  const_iterator set(const std::string &key, const std::string &val);
+
+  /**
+   * Appends a new header. If a header of the same name exists, value(s) is tacked
+   * on that the end of current value(s). 
+   * 
+   * @param pair Contains the name and list of values.
+   *
+   * @return Iterator to header appended. 
+   */
+  const_iterator append(const std::pair<std::string, std::list<std::string> > &pair);
+
+  /**
+   * Appends a new header. If a header of the same name exists, value(s) is tacked
+   * on that the end of current value(s). 
+   * 
+   * @param key Name of header
+   * @param val List of values
+   * 
+   * @return Iterator to header appended. 
+   */
+  const_iterator append(const std::string &key, const std::list<std::string> &val);
+
+  /**
+   * Appends a new header. If a header of the same name exists, value(s) is tacked
+   * on that the end of current value(s). 
+   * 
+   * @param key Name of header
+   * @param val Value
+   * 
+   * @return Iterator to header appended. 
+   */
+  const_iterator append(const std::string &key, const std::string &val);
+
+  /**
+   * Joins provided list of values with delimiter (defaulting to ',').
+   *
+   * @return Composite string
+   */
+  static std::string getJoinedValues(const std::list<std::string> &values, char delimiter = ',');
+
+  /**
+   * Joins values of provided header with delimiter (defaulting to ',').
+   *
+   * @return Composite string if header exists, else empty strings.
+   */
+  std::string getJoinedValues(const std::string &key, char value_delimiter = ',');
+
+  /**
+   * @return True if there are no headers.
+   */
+  bool empty() const;
+
+  /**
+   * @return Largest possible size of underlying map.
+   */
+  size_type max_size() const;
+
+  /**
+   * @return Number of headers currently stored.
+   */
+  size_type size() const;
+
+  typedef std::map<std::string, std::list<std::string> > RequestCookieMap;
+
+  /**
+   * @return Cookies in the "Cookie" headers of a request object.
+   */
+  const RequestCookieMap &getRequestCookies() const;
+
+  struct ResponseCookie {
+    std::string name_;
+    std::string value_;
+    std::string comment_;
+    std::string domain_;
+    int max_age_;
+    std::string path_;
+    bool secure_;
+    int version_;
+    ResponseCookie() : max_age_(0), secure_(false), version_(0) { };
+  };
+
+  /**
+   * @return Cookies in the "Set-Cookie" headers of a response object.
+   */
+  const std::list<ResponseCookie> &getResponseCookies() const;
+
+  /** Adds a request cookie */
+  bool addCookie(const std::string &name, const std::string &value);
+
+  /** Adds a response cookie */
+  bool addCookie(const ResponseCookie &response_cookie);
+  
+  /** Sets, i.e., clears current value and adds new value, of a request cookie */
+  bool setCookie(const std::string &name, const std::string &value);
+
+  /** Sets, i.e., clears current value and adds new value, of a response cookie */
+  bool setCookie(const ResponseCookie &response_cookie);
+
+  /** Deletes a cookie */
+  bool deleteCookie(const std::string &name);
+
+  ~Headers();
+private:
+  HeadersState *state_;
+  bool checkAndInitHeaders() const;
+  void init(void *hdr_buf, void *hdr_loc);
+  void initDetached();
+  void setType(Type type);
+  void updateRequestCookieHeaderFromMap();
+  const_iterator doBasicAppend(const std::pair<std::string, std::list<std::string> > &pair);
+  size_type doBasicErase(const std::string &key);
+  friend class Request;
+  friend class ClientRequest;
+  friend class Response;
+};
+
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/HttpMethod.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/HttpMethod.h b/lib/atscppapi/src/include/atscppapi/HttpMethod.h
new file mode 100644
index 0000000..c07c673
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/HttpMethod.h
@@ -0,0 +1,58 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/**
+ * @file HttpMethod.h
+ * @brief Contains an enumeration and printable strings for Http Methods.
+ */
+#pragma once
+#ifndef ATSCPPAPI_HTTP_METHOD_H_
+#define ATSCPPAPI_HTTP_METHOD_H_
+
+#include <string>
+
+namespace atscppapi {
+
+/**
+ * An enumeration of all available Http Methods.
+ */
+enum HttpMethod {
+  HTTP_METHOD_UNKNOWN = 0,
+  HTTP_METHOD_GET,
+  HTTP_METHOD_POST,
+  HTTP_METHOD_HEAD,
+  HTTP_METHOD_CONNECT,
+  HTTP_METHOD_DELETE,
+  HTTP_METHOD_ICP_QUERY,
+  HTTP_METHOD_OPTIONS,
+  HTTP_METHOD_PURGE,
+  HTTP_METHOD_PUT,
+  HTTP_METHOD_TRACE
+};
+
+/**
+ * An array of printable strings representing of the HttpMethod
+ * \code
+ * cout << HTTP_METHOD_STRINGS[HTTP_METHOD_GET] << endl;
+ * \endcode
+ */
+extern const std::string HTTP_METHOD_STRINGS[];
+
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/HttpStatus.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/HttpStatus.h b/lib/atscppapi/src/include/atscppapi/HttpStatus.h
new file mode 100644
index 0000000..e1ba25b
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/HttpStatus.h
@@ -0,0 +1,104 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/**
+ * @file HttpStatus.h
+ * @brief Contains an enumeration and printable strings for Http Status codes.
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_HTTP_STATUS_H_
+#define ATSCPPAPI_HTTP_STATUS_H_
+
+#include <string>
+
+namespace atscppapi {
+
+/**
+ * An enumeration of all available Http Status Codes.
+ */
+enum HttpStatus
+{
+  HTTP_STATUS_UNKNOWN = 0,
+
+  HTTP_STATUS_CONTINUE = 100,
+  HTTP_STATUS_SWITCHING_PROTOCOL = 101,
+
+  HTTP_STATUS_OK = 200,
+  HTTP_STATUS_CREATED = 201,
+  HTTP_STATUS_ACCEPTED = 202,
+  HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION = 203,
+  HTTP_STATUS_NO_CONTENT = 204,
+  HTTP_STATUS_RESET_CONTENT = 205,
+  HTTP_STATUS_PARTIAL_CONTENT = 206,
+  HTTP_STATUS_MULTI_STATUS = 207,
+  HTTP_STATUS_ALREADY_REPORTED = 208,
+  HTTP_STATUS_IM_USED = 211,
+
+  HTTP_STATUS_MULTIPLE_CHOICES = 300,
+  HTTP_STATUS_MOVED_PERMANENTLY = 301,
+  HTTP_STATUS_MOVED_TEMPORARILY = 302,
+  HTTP_STATUS_SEE_OTHER = 303,
+  HTTP_STATUS_NOT_MODIFIED = 304,
+  HTTP_STATUS_USE_PROXY = 305,
+  HTTP_STATUS_TEMPORARY_REDIRECT = 307,
+  HTTP_STATUS_PERMANENT_REDIRECT = 308,
+
+  HTTP_STATUS_BAD_REQUEST = 400,
+  HTTP_STATUS_UNAUTHORIZED = 401,
+  HTTP_STATUS_PAYMENT_REQUIRED = 402,
+  HTTP_STATUS_FORBIDDEN = 403,
+  HTTP_STATUS_NOT_FOUND = 404,
+  HTTP_STATUS_METHOD_NOT_ALLOWED = 405,
+  HTTP_STATUS_NOT_ACCEPTABLE = 406,
+  HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED = 407,
+  HTTP_STATUS_REQUEST_TIMEOUT = 408,
+  HTTP_STATUS_CONFLICT = 409,
+  HTTP_STATUS_GONE = 410,
+  HTTP_STATUS_LENGTH_REQUIRED = 411,
+  HTTP_STATUS_PRECONDITION_FAILED = 412,
+  HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE = 413,
+  HTTP_STATUS_REQUEST_URI_TOO_LONG = 414,
+  HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415,
+  HTTP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE = 416,
+  HTTP_STATUS_EXPECTATION_FAILED = 417,
+  HTTP_STATUS_UNPROCESSABLE_ENTITY = 422,
+  HTTP_STATUS_LOCKED = 423,
+  HTTP_STATUS_FAILED_DEPENDENCY = 424,
+  HTTP_STATUS_UPGRADE_REQUIRED = 426,
+  HTTP_STATUS_PRECONDITION_REQUIRED = 428,
+  HTTP_STATUS_TOO_MANY_REQUESTS = 429,
+  HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
+
+  HTTP_STATUS_INTERNAL_SERVER_ERROR = 500,
+  HTTP_STATUS_NOT_IMPLEMENTED = 501,
+  HTTP_STATUS_BAD_GATEWAY = 502,
+  HTTP_STATUS_SERVICE_UNAVAILABLE = 503,
+  HTTP_STATUS_GATEWAY_TIMEOUT = 504,
+  HTTP_STATUS_HTTPVER_NOT_SUPPORTED = 505,
+  HTTP_STATUS_VARIANT_ALSO_NEGOTIATES = 506,
+  HTTP_STATUS_INSUFFICIENT_STORAGE = 507,
+  HTTP_STATUS_LOOP_DETECTED = 508,
+  HTTP_STATUS_NOT_EXTENDED = 510,
+  HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED = 511
+
+};
+
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/HttpVersion.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/HttpVersion.h b/lib/atscppapi/src/include/atscppapi/HttpVersion.h
new file mode 100644
index 0000000..fdbd639
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/HttpVersion.h
@@ -0,0 +1,52 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/**
+ * @file HttpVersion.h
+ * @brief Contains an enumeration and printable strings for Http Versions.
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_HTTP_VERSION_H_
+#define ATSCPPAPI_HTTP_VERSION_H_
+
+#include <string>
+
+namespace atscppapi {
+
+/**
+ * An enumeration of all available Http Versions.
+ */
+enum HttpVersion {
+  HTTP_VERSION_UNKNOWN = 0,
+  HTTP_VERSION_0_9,
+  HTTP_VERSION_1_0,
+  HTTP_VERSION_1_1,
+};
+
+/**
+ * An array of printable strings representing of the HttpVersion
+ * \code
+ * cout << HTTP_VERSION_STRINGS[HTTP_VERSION_1_1] << endl;
+ * \endcode
+ */
+extern const std::string HTTP_VERSION_STRINGS[];
+
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/Logger.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Logger.h b/lib/atscppapi/src/include/atscppapi/Logger.h
new file mode 100644
index 0000000..ef6e3a6
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/Logger.h
@@ -0,0 +1,268 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/**
+ * @file Logger.h
+ * @brief Helpers and Classes related to Logging
+ *
+ * @warning Log rolling doesn't work correctly in 3.2.x see:
+ *   https://issues.apache.org/jira/browse/TS-1813
+ *   Apply the patch in TS-1813 to correct log rolling in 3.2.x
+ *
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_LOGGER_H_
+#define ATSCPPAPI_LOGGER_H_
+
+#include <string>
+#include <atscppapi/noncopyable.h>
+
+#if !defined(ATSCPPAPI_PRINTFLIKE)
+#if defined(__GNUC__) || defined(__clang__)
+/**
+ * This macro will tell GCC that the function takes printf like arugments
+ * this is helpful because it can produce better warning and error messages
+ * when a user doesn't use the methods correctly.
+ *
+ * @private
+ */
+#define ATSCPPAPI_PRINTFLIKE(fmt, arg) __attribute__((format(printf, fmt, arg)))
+#else
+#define ATSCPPAPI_PRINTFLIKE(fmt, arg)
+#endif
+#endif
+
+/**
+ * A helper macro for Logger objects that allows you to easily add a debug level message
+ * which will include file, line, and function name with the message. It's very easy to use:
+ * \code
+ *  // Suppose you have already created a Logger named logger:
+ *  LOG_DEBUG(logger, "This is a test DEBUG message: %s", "hello");
+ *  // Outputs [file.cc:125, function()] [DEBUG] This is a test DEBUG message: hello.
+ * \endcode
+ */
+#define LOG_DEBUG(log, fmt, ...) \
+  do { \
+    (log).logDebug("[%s:%d, %s()] " fmt, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \
+  } while (false)
+
+/**
+ * A helper macro for Logger objects that allows you to easily add a info level message
+ * which will include file, line, and function name with the message. See example in LOG_DEBUG
+ */
+#define LOG_INFO(log, fmt, ...) \
+  do { \
+    (log).logInfo("[%s:%d, %s()] " fmt, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \
+  } while (false)
+
+/**
+ * A helper macro for Logger objects that allows you to easily add a error level message
+ * which will include file, line, and function name with the message.  See example in LOG_DEBUG
+ */
+#define LOG_ERROR(log, fmt, ...) \
+  do { \
+    (log).logError("[%s:%d, %s()] " fmt, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \
+  } while (false)
+
+/**
+ * We forward declare this because if we didn't we end up writing our
+ * own version to do the vsnprintf just to call TSDebug and have it do
+ * an unncessary vsnprintf.
+ *
+ * @private
+ */
+extern "C" void TSDebug(const char *tag, const char *fmt, ...) ATSCPPAPI_PRINTFLIKE(2,3);
+
+/**
+ * We forward declare this because if we didn't we end up writing our
+ * own version to do the vsnprintf just to call TSError and have it do
+ * an unncessary vsnprintf.
+ *
+ * @private
+ */
+extern "C" void TSError(const char *fmt, ...) ATSCPPAPI_PRINTFLIKE(1,2);
+
+// This is weird, but see the following:
+//   http://stackoverflow.com/questions/5641427/how-to-make-preprocessor-generate-a-string-for-line-keyword
+#define STRINGIFY0(x) #x
+#define STRINGIFY(x) STRINGIFY0(x)
+#define LINE_NO STRINGIFY(__LINE__)
+
+/**
+ * A helper macro to get access to the Diag messages available in traffic server. These can be enabled
+ * via traffic_server -T "tag.*" or since this macro includes the file can you further refine to an
+ * individual file or even a particular line! This can also be enabled via records.config.
+ */
+#define TS_DEBUG(tag, fmt, ...) \
+  do { \
+    TSDebug(tag "." __FILE__ ":" LINE_NO , "[%s()] " fmt, __FUNCTION__, ## __VA_ARGS__); \
+  } while (false)
+
+/**
+ * A helper macro to get access to the error.log messages available in traffic server. This
+ * will also output a DEBUG message visible via traffic_server -T "tag.*", or by enabling the
+ * tag in records.config.
+ */
+#define TS_ERROR(tag, fmt, ...) \
+  do { \
+    TS_DEBUG(tag, "[ERROR] " fmt, ## __VA_ARGS__); \
+    TSError("[%s] [%s:%d, %s()] " fmt, tag, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \
+  } while (false)
+
+namespace atscppapi {
+
+class LoggerState;
+
+/**
+ * @brief Create log files that are automatically rolled and cleaned up as space is required.
+ *
+ * Log files created using the Logger class will be placed in the same directory as
+ * other log files, that directory is specified in records.config. All of the logging
+ * configuration such as max space available for all logs includes any logs created
+ * using the Logger class.
+ *
+ * Loggers are very easy to use and a full example is available in examples/logger_example/,
+ * a simple example is:
+ * \code
+ * // See Logger::init() for an explanation of the init() parameters.
+ * log.init("logger_example", true, true, Logger::LOG_LEVEL_DEBUG);
+ * // You have two ways to log to a logger, you can log directly on the object itself:
+ * log.logInfo("Hello World from: %s", argv[0]);
+ * // Alternatively you can take advantage of the super helper macros for logging
+ * // that will include the file, function, and line number automatically as part
+ * // of the log message:
+ * LOG_INFO(log, "Hello World with more info from: %s", argv[0]);
+ * \endcode
+ *
+ * @warning Log rolling doesn't work correctly in 3.2.x see:
+ *   https://issues.apache.org/jira/browse/TS-1813
+ *   Apply the patch in TS-1813 to correct log rolling in 3.2.x
+ *
+ */
+class Logger : noncopyable {
+public:
+
+  /**
+   * The available log levels
+   */
+  enum LogLevel {
+    LOG_LEVEL_NO_LOG = 128, /**< This log level is used to disable all logging */
+    LOG_LEVEL_DEBUG = 1, /**< This log level is used for DEBUG level logging (DEBUG + INFO + ERROR) */
+    LOG_LEVEL_INFO = 2, /**< This log level is used for INFO level logging (INFO + ERROR) */
+    LOG_LEVEL_ERROR = 4 /**< This log level is used for ERROR level logging (ERROR ONLY) */
+  };
+
+  Logger();
+  ~Logger();
+
+  /**
+   * You must always init() a Logger before you begin logging. If you do not call init() nothing will
+   * happen.
+   *
+   * @param file The name of the file to create in the logging directory, if you do not specify an extension .log will be used.
+   * @param add_timestamp Prepend a timestamp to the log lines, the default value is true.
+   * @param rename_file If a file already exists by the same name it will attempt to rename using a scheme that appends .1, .2, and so on,
+   *   the default value for this argument is true.
+   * @param level the default log level to use when creating the logger, this is set to LOG_LEVEL_INFO by default.
+   * @param rolling_enabled if set to true this will enable log rolling on a periodic basis, this is enabled by default.
+   * @param rolling_interval_seconds how frequently to roll the longs in seconds, this is set to 3600 by default (one hour).
+   * @return returns true if the logger was successfully created and initialized.
+   * @see LogLevel
+   */
+  bool init(const std::string &file, bool add_timestamp = true, bool rename_file = true,
+      LogLevel level = LOG_LEVEL_INFO, bool rolling_enabled = true, int rolling_interval_seconds = 3600);
+
+  /**
+   * Allows you to change the rolling interval in seconds
+   * @param seconds the number of seconds between rolls
+   */
+  void setRollingIntervalSeconds(int seconds);
+
+  /**
+   * @return the number of seconds between log rolls.
+   */
+  int getRollingIntervalSeconds() const;
+
+  /**
+   * Enables or disables log rolling
+   * @param enabled true to enable log rolling, false to disable it.
+   */
+  void setRollingEnabled(bool enabled);
+
+  /**
+   * @return A boolean value which represents whether rolling is enabled or disabled.
+   */
+  bool isRollingEnabled() const;
+
+  /**
+   * Change the log level
+   *
+   * @param level the new log level to use
+   * @see LogLevel
+   */
+  void setLogLevel(Logger::LogLevel level);
+
+  /**
+   * @return The current log level.
+   * @see LogLevel
+   */
+  Logger::LogLevel getLogLevel() const;
+
+  /**
+   * This method allows you to flush any log lines that might have been buffered.
+   * @warning This method can cause serious performance degredation so you should only
+   * use it when absolutely necessary.
+   */
+  void flush();
+
+  /**
+   * This method writes a DEBUG level message to the log file, the LOG_DEBUG
+   * macro in Logger.h should be used in favor of these when possible because it
+   * will produce a much more rich debug message.
+   *
+   * Sample usage:
+   * \code
+   * log.logDebug("Hello you are %d years old", 27);
+   * \endcode
+   */
+  void logDebug(const char *fmt, ...) ATSCPPAPI_PRINTFLIKE(2,3);
+
+  /**
+   * This method writes an INFO level message to the log file, the LOG_INFO
+   * macro in Logger.h should be used in favor of these when possible because it
+   * will produce a much more rich info message.
+   */
+  void logInfo(const char *fmt, ...) ATSCPPAPI_PRINTFLIKE(2,3);
+
+  /**
+   * This method writes an ERROR level message to the log file, the LOG_ERROR
+   * macro in Logger.h should be used in favor of these when possible because it
+   * will produce a much more rich error message.
+   */
+  void logError(const char *fmt, ...) ATSCPPAPI_PRINTFLIKE(2,3);
+private:
+  LoggerState *state_; /**< Internal state for the Logger */
+};
+
+} /* atscppapi */
+
+
+
+
+#endif /* ATSCPPAPI_LOGGER_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/Mutex.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Mutex.h b/lib/atscppapi/src/include/atscppapi/Mutex.h
new file mode 100644
index 0000000..6044477
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/Mutex.h
@@ -0,0 +1,250 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/**
+ * @file Mutex.h
+ * @brief Contains Mutex related classes for creating a Mutex and locking a Mutex in a specific scope.
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_MUTEX_H_
+#define ATSCPPAPI_MUTEX_H_
+
+#include <pthread.h>
+#include <atscppapi/noncopyable.h>
+#include <atscppapi/shared_ptr.h>
+
+namespace atscppapi {
+
+/**
+ * @brief A mutex is mutual exclusion: a blocking lock.
+ *
+ * The Mutex class uses pthreads for its implmentation.
+ *
+ * @see ScopedMutexLock
+ * @see ScopedMutexTryLock
+ * @see ScopedSharedMutexLock
+ * @see ScopedSharedMutexTryLock
+ */
+class Mutex: noncopyable {
+public:
+
+  /**
+   * The available types of Mutexes.
+   */
+  enum Type {
+    TYPE_NORMAL = 0, /**< This type of Mutex will deadlock if locked by a thread already holding the lock */
+    TYPE_RECURSIVE, /**< This type of Mutex will allow a thread holding the lock to lock it again; however, it must be unlocked the same number of times */
+    TYPE_ERROR_CHECK /**< This type of Mutex will return errno = EDEADLCK if a thread would deadlock by taking the lock after it already holds it */
+  };
+
+  /**
+   * Create a mutex
+   *
+   * @param type The Type of Mutex to create, the default is TYPE_NORMAL.
+   * @see Type
+   */
+  Mutex(Type type = TYPE_NORMAL) {
+    pthread_mutexattr_t attr;
+    pthread_mutexattr_init(&attr);
+
+    switch(type) {
+    case TYPE_RECURSIVE:
+     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+     break;
+    case TYPE_ERROR_CHECK:
+     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
+     break;
+    case TYPE_NORMAL:
+    default:
+     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
+     break;
+    }
+
+    pthread_mutex_init(&mutex, &attr);
+  }
+
+  ~Mutex() {
+    pthread_mutex_destroy(&mutex);
+  }
+
+  /**
+   * Try to take the lock, this call will NOT block if the mutex cannot be taken.
+   * @return Returns true if the lock was taken, false if it was not. This call obviously will not block.
+   */
+  bool tryLock() {
+    return !pthread_mutex_trylock(&mutex);
+  }
+
+  /**
+   * Block until the lock is taken, when this call returns the thread will be holding the lock.
+   */
+  void lock() {
+    pthread_mutex_lock(&mutex);
+  }
+
+  /**
+   * Unlock the lock, this call is nonblocking.
+   */
+  void unlock() {
+    pthread_mutex_unlock(&mutex);
+  }
+private:
+  pthread_mutex_t mutex; /**< Internal mutex identifier */
+};
+
+/**
+ * @brief Take a Mutex reference and lock inside a scope and unlock when the scope is exited.
+ *
+ * This is an RAII implementation which will lock a mutex at the start of the
+ * scope and unlock it when the scope is exited.
+ *
+ * @see Mutex
+ */
+class ScopedMutexLock: noncopyable {
+public:
+  /**
+   * Create the scoped mutex lock, once this object is constructed the lock will be held by the thread.
+   * @param mutex a reference to a Mutex.
+   */
+  explicit ScopedMutexLock(Mutex &mutex) :
+      mutex_(mutex) {
+    mutex_.lock();
+  }
+
+  /**
+   * Unlock the mutex.
+   */
+  ~ScopedMutexLock() {
+    mutex_.unlock();
+  }
+private:
+  Mutex &mutex_;
+};
+
+/**
+ * @brief Take a shared_ptr to a Mutex and lock inside a scope and unlock when the scope is exited.
+ *
+ * This is an RAII implementation which will lock a mutex at the start of the
+ * scope and unlock it when the scope is exited.
+ *
+ * @see Mutex
+ */
+class ScopedSharedMutexLock: noncopyable {
+public:
+  /**
+   * Create the scoped mutex lock, once this object is constructed the lock will be held by the thread.
+   * @param mutex a shared pointer to a Mutex.
+   */
+  explicit ScopedSharedMutexLock(shared_ptr<Mutex> mutex) :
+      mutex_(mutex) {
+    mutex_->lock();
+  }
+
+  /**
+   * Unlock the mutex.
+   */
+  ~ScopedSharedMutexLock() {
+    mutex_->unlock();
+  }
+private:
+  shared_ptr<Mutex> mutex_;
+};
+
+/**
+ * @brief Take a Mutex reference and try to lock inside a scope and unlock when the scope is exited (if the lock was taken).
+ *
+ * This is an RAII implementation which will lock a mutex at the start of the
+ * scope and unlock it when the scope is exited if the lock was taken.
+ *
+ * @see Mutex
+ */
+class ScopedMutexTryLock: noncopyable {
+public:
+  /**
+   * Try to create the scoped mutex lock, if you should check hasLock() to determine if this object was successfully able to take the lock.
+   * @param mutex a shared pointer to a Mutex.
+   */
+  explicit ScopedMutexTryLock(Mutex &mutex) :
+      mutex_(mutex), has_lock_(false) {
+    has_lock_ = mutex_.tryLock();
+  }
+
+  /**
+   * Unlock the mutex (if we hold the lock)
+   */
+  ~ScopedMutexTryLock() {
+    if (has_lock_) {
+      mutex_.unlock();
+    }
+  }
+
+  /**
+   * @return True if the lock was taken, False if it was not taken.
+   */
+  bool hasLock() {
+    return has_lock_;
+  }
+private:
+  Mutex &mutex_;
+  bool has_lock_;
+};
+
+/**
+ * @brief Take a shared_ptr to a Mutex and try to lock inside a scope and unlock when the scope is exited (if the lock was taken).
+ *
+ * This is an RAII implementation which will lock a mutex at the start of the
+ * scope and unlock it when the scope is exited if the lock was taken.
+ *
+ * @see Mutex
+ */
+class ScopedSharedMutexTryLock: noncopyable {
+public:
+  /**
+   * Try to create the scoped mutex lock, if you should check hasLock() to determine if this object was successfully able to take the lock.
+   * @param mutex a shared pointer to a Mutex.
+   */
+  explicit ScopedSharedMutexTryLock(shared_ptr<Mutex> mutex) :
+      mutex_(mutex), has_lock_(false) {
+    has_lock_ = mutex_->tryLock();
+  }
+
+  /**
+   * Unlock the mutex (if we hold the lock)
+   */
+  ~ScopedSharedMutexTryLock() {
+    if (has_lock_) {
+      mutex_->unlock();
+    }
+  }
+
+  /**
+   * @return True if the lock was taken, False if it was not taken.
+   */
+  bool hasLock() {
+    return has_lock_;
+  }
+private:
+  shared_ptr<Mutex> mutex_;
+  bool has_lock_;
+};
+
+} /* atscppapi */
+
+
+#endif /* ATSCPPAPI_MUTEX_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/Plugin.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Plugin.h b/lib/atscppapi/src/include/atscppapi/Plugin.h
new file mode 100644
index 0000000..677a3bd
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/Plugin.h
@@ -0,0 +1,106 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+/**
+ * @file Plugin.h
+ *
+ * @brief Contains the base interface used in creating Global and Transaciton plugins.
+ * \note This interface can never be implemented directly, it should be implemented
+ *   through extending GlobalPlugin, TransactionPlugin, or TransformationPlugin.
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_PLUGIN_H_
+#define ATSCPPAPI_PLUGIN_H_
+
+#include <atscppapi/Transaction.h>
+#include <atscppapi/noncopyable.h>
+
+namespace atscppapi {
+
+/**
+ * @brief The base interface used when creating a Plugin.
+ *
+ * \note This interface can never be implemented directly, it should be implemented
+ *   through extending GlobalPlugin, TransactionPlugin, or TransformationPlugin.
+ *
+ * @see TransactionPlugin
+ * @see GlobalPlugin
+ * @see TransformationPlugin
+ */
+class Plugin: noncopyable {
+public:
+  /**
+   * A enumeration of the available types of Hooks. These are used with GlobalPlugin::registerHook()
+   * and TransactionPlugin::registerHook().
+   */
+  enum HookType {
+    HOOK_READ_REQUEST_HEADERS_PRE_REMAP = 0, /**< This hook will be fired before remap has occured. */
+    HOOK_READ_REQUEST_HEADERS_POST_REMAP, /**< This hook will be fired directly after remap has occured. */
+    HOOK_SEND_REQUEST_HEADERS, /**< This hook will be fired right before request headers are sent to the origin */
+    HOOK_READ_RESPONSE_HEADERS, /**< This hook will be fired right after response headers have been read from the origin */
+    HOOK_SEND_RESPONSE_HEADERS, /**< This hook will be fired right before the response headers are sent to the client */
+    HOOK_OS_DNS /**< This hook will be fired right after the OS DNS lookup */
+  };
+
+  /**
+   * This method must be implemented when you hook HOOK_READ_REQUEST_HEADERS_PRE_REMAP
+   */
+  virtual void handleReadRequestHeadersPreRemap(Transaction &transaction) { transaction.resume(); };
+
+  /**
+   * This method must be implemented when you hook HOOK_READ_REQUEST_HEADERS_POST_REMAP
+   */
+  virtual void handleReadRequestHeadersPostRemap(Transaction &transaction) { transaction.resume(); };
+
+  /**
+   * This method must be implemented when you hook HOOK_SEND_REQUEST_HEADERS
+   */
+  virtual void handleSendRequestHeaders(Transaction &transaction) { transaction.resume(); };
+
+  /**
+   * This method must be implemented when you hook HOOK_READ_RESPONSE_HEADERS
+   */
+  virtual void handleReadResponseHeaders(Transaction &transaction) { transaction.resume(); };
+
+  /**
+   * This method must be implemented when you hook HOOK_SEND_RESPONSE_HEADERS
+   */
+  virtual void handleSendResponseHeaders(Transaction &transaction) { transaction.resume(); };
+
+  /**
+   * This method must be implemented when you hook HOOK_OS_DNS
+   */
+  virtual void handleOsDns(Transaction &transaction) { transaction.resume(); };
+
+  virtual ~Plugin() { };
+protected:
+  /**
+  * \note This interface can never be implemented directly, it should be implemented
+  *   through extending GlobalPlugin, TransactionPlugin, or TransformationPlugin.
+  *
+  * @private
+  */
+  Plugin() { };
+};
+
+/**< Human readable strings for each HookType, you can access them as HOOK_TYPE_STRINGS[HOOK_OS_DNS] for example. */
+extern const std::string HOOK_TYPE_STRINGS[];
+
+} /* atscppapi */
+
+#endif /* ATSCPPAPI_GLOBALPLUGIN_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/PluginInit.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/PluginInit.h b/lib/atscppapi/src/include/atscppapi/PluginInit.h
new file mode 100644
index 0000000..ecd72e4
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/PluginInit.h
@@ -0,0 +1,55 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+/**
+ * @file PluginInit.h
+ * @brief Provides hooks that plugins have to implement. ATS will invoke these when loading the plugin .so files.
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_PLUGININIT_H_
+#define ATSCPPAPI_PLUGININIT_H_
+
+extern "C" {
+
+/** 
+ * Invoked for "general" plugins - listed in plugin.config. The arguments in the
+ * plugin.config line are provided in this invocation.
+ *
+ * @param argc Count of arguments
+ * @param argv Array of pointers pointing to arguments
+ */
+void TSPluginInit(int argc, const char *argv[]);
+
+enum TsReturnCode { TS_ERROR = -1, TS_SUCCESS = 0 };
+
+/** 
+ * Invoked for remap plugins - listed in remap.config. The arguments provided as @pparam
+ * in the remap.config line are provided in this invocation.
+ *
+ * @param argc Count of arguments
+ * @param argv Array of pointers pointing to arguments
+ * @param instance_handle Should be passed to the RemapPlugin constructor
+ * @param errbuf Not used
+ * @param errbuf_size Not used
+ */
+TsReturnCode TSRemapNewInstance(int argc, char *argv[], void **instance_handle, char *errbuf, int errbuf_size);
+
+}
+
+
+#endif /* ATSCPPAPI_PLUGININIT_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/RemapPlugin.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/RemapPlugin.h b/lib/atscppapi/src/include/atscppapi/RemapPlugin.h
new file mode 100644
index 0000000..2a80291
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/RemapPlugin.h
@@ -0,0 +1,69 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/**
+ * @file RemapPlugin.h
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_REMAP_PLUGIN_H_
+#define ATSCPPAPI_REMAP_PLUGIN_H_
+
+#include "atscppapi/Transaction.h"
+#include "atscppapi/Url.h"
+
+namespace atscppapi {
+
+/** 
+ * @brief Base class that remap plugins should extend.
+ */
+class RemapPlugin {
+public:
+  /**
+   * Constructor
+   * 
+   * @param instance_handle The instance_handle argument received in TSRemapInit() should be passed here.
+   */
+  RemapPlugin(void **instance_handle);
+
+  enum Result { RESULT_ERROR = 0, RESULT_NO_REMAP, RESULT_DID_REMAP, RESULT_NO_REMAP_STOP,
+                RESULT_DID_REMAP_STOP };
+
+  /** 
+   * Invoked when a request matches the remap.config line - implementation should perform the
+   * remap. The client's URL is in the transaction and that's where it should be modified.
+   * 
+   * @param map_from_url The map from URL specified in the remap.config line.
+   * @param map_to_url The map to URL specified in the remap.config line.
+   * @param transaction Transaction
+   * @param redirect Output argument that should be set to true if the (new) url should be used
+   *                 as a redirect. 
+   *
+   * @return Result of the remap - will dictate futher processing by the system.
+   */
+  virtual Result doRemap(const Url &map_from_url, const Url &map_to_url, Transaction &transaction,
+                         bool &redirect) {
+    return RESULT_NO_REMAP;
+  }
+
+  virtual ~RemapPlugin() { }
+};
+
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/Request.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Request.h b/lib/atscppapi/src/include/atscppapi/Request.h
new file mode 100644
index 0000000..8831725
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/Request.h
@@ -0,0 +1,72 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+/**
+ * @file Request.h
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_REQUEST_H_
+#define ATSCPPAPI_REQUEST_H_
+
+#include <atscppapi/Headers.h>
+#include <atscppapi/HttpVersion.h>
+#include <atscppapi/HttpMethod.h>
+#include <atscppapi/Url.h>
+#include <atscppapi/noncopyable.h>
+
+namespace atscppapi {
+
+class Transaction;
+struct RequestState;
+
+/**
+ * @brief Encapsulates a request.
+ */
+class Request: noncopyable {
+public:
+  Request();
+
+  /**
+   * Constructed with an initial URL.
+   */
+  Request(const std::string &url, HttpMethod method = HTTP_METHOD_GET, HttpVersion version = HTTP_VERSION_1_1); 
+
+  /** @return HTTP method of the request */
+  HttpMethod getMethod() const;
+
+  /** @return URL of the request */
+  Url &getUrl();
+
+  /** @return HTTP version of the request */
+  HttpVersion getVersion() const;
+
+  /** @return Headers of the request */
+  Headers &getHeaders() const;
+
+  ~Request();
+private:
+  Request(void *hdr_buf, void *hdr_loc);
+  RequestState *state_;
+  void init(void *hdr_buf, void *hdr_loc);
+  friend class Transaction;
+  friend class ClientRequest;
+};
+
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/Response.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Response.h b/lib/atscppapi/src/include/atscppapi/Response.h
new file mode 100644
index 0000000..f309bc1
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/Response.h
@@ -0,0 +1,71 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+/**
+ * @file Response.h
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_RESPONSE_H_
+#define ATSCPPAPI_RESPONSE_H_
+
+#include <atscppapi/Headers.h>
+#include <atscppapi/HttpVersion.h>
+#include <atscppapi/HttpStatus.h>
+
+namespace atscppapi {
+
+// forward declarations
+struct ResponseState;
+namespace utils { class internal; }
+
+/**
+ * @brief Encapsulates a response.
+ */
+class Response: noncopyable {
+public:
+  Response();
+
+  /** @return HTTP version of the response */
+  HttpVersion getVersion() const;
+
+  /** @return Status code of the response */
+  HttpStatus getStatusCode() const;
+
+  /** @param New status code to set */
+  void setStatusCode(HttpStatus);
+
+  /** @return Reason phrase of the response */
+  const std::string &getReasonPhrase() const;
+
+  /** @param New reason phrase to set */
+  void setReasonPhrase(const std::string &);
+
+  /** @return Headers of the response */
+  Headers &getHeaders() const;
+
+  ~Response();
+private:
+  ResponseState *state_;
+  void init(void *hdr_buf, void *hdr_loc);
+  friend class Transaction;
+  friend class utils::internal;
+};
+
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/Stat.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Stat.h b/lib/atscppapi/src/include/atscppapi/Stat.h
new file mode 100644
index 0000000..d665d1a
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/Stat.h
@@ -0,0 +1,106 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+/**
+ * @file Stat.h
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_STAT_H_
+#define ATSCPPAPI_STAT_H_
+
+#include <atscppapi/noncopyable.h>
+#include <stdint.h>
+#include <string>
+
+namespace atscppapi {
+
+/**
+ * @brief A Stat is an atomic variable that can be used to store counters, averages, time averages, or summations.
+ *
+ * All stats are exposed through the traffic_line program included with Apache Traffic Server. Additionally,
+ * if you've enabled HttpStats all Stats you define will be displayed there. Stats can be read via
+ * traffic_line -r stat_name.
+ *
+ * Stats are very easy to use, here is a simple example of how you can create a counter and increment its
+ * value:
+ * \code
+ *  Stat stat;
+ *  stat.init("stat_name");
+    stat.inc();
+ * \endcode
+ *
+ * A full example is available in examples/stat_example/.
+ */
+class Stat : noncopyable {
+public:
+  /**
+   * The available Stat types.
+   */
+  enum SyncType {
+    SYNC_SUM = 0, /**< The stat will sum all values from a stat.inc(VAL) */
+    SYNC_COUNT, /**< The stat will count all calls to stat.inc(VAL) */
+    SYNC_AVG, /**< The stat will keep an average after call calls to stat.inc(VAL) */
+    SYNC_TIMEAVG /**< The stat will keep a time average of all calls to stat.inc(VAL) */
+  };
+
+  Stat();
+  ~Stat();
+
+  /**
+   * You must initialize your Stat with a call to this init() method.
+   *
+   * @param name The string name of the stat, this will be visbible via traffic_line -r, or through http stats.
+   * @param type The SyncType of the Stat, this decides how TrafficServer will treat your inputs. The default
+   *   value is SYNC_COUNT.
+   * @param persistent This determines if your Stats will persist, the default value is false.
+   * @return True if the stat was successfully created and false otherwise.
+   *
+   * @see SyncType
+   */
+  bool init(std::string name, Stat::SyncType type = SYNC_COUNT, bool persistent = false);
+
+  /**
+   * This method allows you to increment a stat by a certain amount.
+   * @param amount the amount to increment the stat by the default value is 1.
+   */
+  void increment(int64_t amount = 1);
+
+  /**
+   * This method allows you to decrement a stat by a certain amount.
+   * @param amount the amount to decrement the stat by the default value is 1.
+   */
+  void decrement(int64_t amount = 1);
+
+  /**
+   * This method returns the current value of the stat.
+   * @return The value of the stat.
+   */
+  int64_t get() const;
+
+  /** This method sets the value of the stat.
+   * @param value the value to set the stat to.
+   */
+  void set(int64_t value);
+private:
+  int stat_id_; /**< The internal stat ID */
+};
+
+} /* atscppapi */
+
+
+#endif /* ATSCPPAPI_STAT_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/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
new file mode 100644
index 0000000..3610d1b
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/Transaction.h
@@ -0,0 +1,314 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+/**
+ * @file Transaction.h
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_TRANSACTION_H_
+#define ATSCPPAPI_TRANSACTION_H_
+
+#include <sys/socket.h>
+#include <stdint.h>
+#include <list>
+#include "atscppapi/Request.h"
+#include "atscppapi/shared_ptr.h"
+#include "atscppapi/ClientRequest.h"
+#include "atscppapi/Response.h"
+
+namespace atscppapi {
+
+// forward declarations
+class TransactionPlugin;
+class TransactionState;
+namespace utils { class internal; }
+
+/**
+ * @brief Transactions are the object containing all the state related to a HTTP Transaction
+ *
+ * @warning Transactions should never be directly created by the user, they will always be automatically
+ * created and destroyed as they are needed. Transactions should never be saved beyond the
+ * scope of the function in which they are delivered otherwise undefined behaviour will result.
+ */
+class Transaction: noncopyable {
+public:
+  /**
+   * @brief ContextValues are a mechanism to share data between plugins using the atscppapi.
+   *
+   * Any data can be shared so long as it extends ContextValue, a simple example might
+   * be:
+   *
+   * \code
+   *     struct mydata : ContextValue {
+   *       int id_;
+   *       string foo_;
+   *       mydata(int id, string foo) : id_(id), foo_(foo) { }
+   *     }
+   *
+   *     Transaction.setContextValue("some-key", shared_ptr(new mydata(12, "hello")));
+   *
+   *     // From another plugin you'll have access to this contextual data:
+   *     shared_ptr<Transaction.getContextValue("some-key")
+   *
+   * \endcode
+   *
+   * Because getContextValue() and setContextValue()
+   * take shared pointers you dont have to worry about the cleanup as that will happen automatically so long
+   * as you dont have shared_ptrs that cannot go out of scope.
+   */
+  class ContextValue {
+  public:
+    virtual ~ContextValue() { }
+  };
+
+  ~Transaction();
+
+  /**
+   * Context Values are a way to share data between plugins, the key is always a string
+   * and the value can be a shared_ptr to any type that extends ContextValue.
+   * @param key the key to search for.
+   * @return Shared pointer that is correctly initialized if the
+   *         value existed. It should be checked with .get() != NULL before use.
+   */
+  shared_ptr<ContextValue> getContextValue(const std::string &key);
+
+  /**
+   * Context Values are a way to share data between plugins, the key is always a string
+   * and the value can be a shared_ptr to any type that extends ContextValue.
+   * @param key the key to insert.
+   * @param value a shared pointer to a class that extends ContextValue.
+   */
+  void setContextValue(const std::string &key, shared_ptr<ContextValue> value);
+
+  /**
+   * Causes the Transaction to continue on to other states in the HTTP state machine
+   * If you do not call resume() on a Transaction it will remain in that state until
+   * it's advanced out by a call to resume() or error().
+   */
+  void resume();
+
+  /**
+   * Causes the Transaction to advance to the error state in the HTTP state machine.
+   * @see error(const std::string &)
+   */
+  void error();
+
+  /**
+   * Causes the Transaction to advance to the error state in the HTTP state machine with
+   * a specific error message displayed. This is functionally equivalent to the following:
+   *
+   * \code
+   * setErrorBody(content);
+   * error();
+   * \endcode
+   *
+   * @param content the error page body.
+   */
+  void error(const std::string &content);
+
+  /**
+   * Sets the error body page but this method does not advance the state machine to the error state.
+   * To do that you must explicitally call error().
+   *
+   * @param content the error page content.
+   */
+  void setErrorBody(const std::string &content);
+
+  /**
+   * Get the clients address
+   * @return The sockaddr structure representing the client's address
+   * @see atscppapi::utils::getIpString() in atscppapi/utils.h
+   * @see atscppapi::utils::getPort() in atscppapi/utils.h
+   * @see atscppapi::utils::getIpPortString in atscppapi/utils.h
+   */
+  const sockaddr *getClientAddress() const;
+
+  /**
+   * Get the incoming address
+   * @return The sockaddr structure representing the incoming address
+   * @see atscppapi::utils::getIpString() in atscppapi/utils.h
+   * @see atscppapi::utils::getPort() in atscppapi/utils.h
+   * @see atscppapi::utils::getIpPortString in atscppapi/utils.h
+   */
+  const sockaddr *getIncomingAddress() const;
+
+  /**
+   * Get the server address
+   * @return The sockaddr structure representing the server's address
+   * @see atscppapi::utils::getIpString() in atscppapi/utils.h
+   * @see atscppapi::utils::getPort() in atscppapi/utils.h
+   * @see atscppapi::utils::getIpPortString in atscppapi/utils.h
+   */
+  const sockaddr *getServerAddress() const;
+
+  /**
+   * Get the next hop address
+   * @return The sockaddr structure representing the next hop's address
+   * @see atscppapi::utils::getIpString() in atscppapi/utils.h
+   * @see atscppapi::utils::getPort() in atscppapi/utils.h
+   * @see atscppapi::utils::getIpPortString in atscppapi/utils.h
+   */
+  const sockaddr *getNextHopAddress() const;
+
+
+  /**
+   * Set the incoming port on the Transaction
+   *
+   * @param port is the port to set as the incoming port on the transaction
+   */
+  bool setIncomingPort(uint16_t port);
+
+  /**
+   * Sets the server address on the Transaction to a populated sockaddr *
+   *
+   * @param sockaddr* the sockaddr structure populated as the server address.
+   */
+  bool setServerAddress(const sockaddr *);
+
+  /**
+   * Returns a boolean value if the request is an internal request.
+   * A request is an internal request if it originates from within traffic server.
+   * An example would be using TSFetchUrl (or the atscppapi equivalent of AsyncHttpFetch)
+   * to make another request along with the original request. The secondary request
+   * originated within traffic server and is an internal request.
+   *
+   * @return boolean value specifying if the request was an internal request.
+   */
+  bool isInternalRequest() const;
+
+  /**
+   * Returns the ClientRequest object for the incoming request from the client.
+   *
+   * @return ClientRequest object that can be used to manipulate the incoming request from the client.
+   */
+  ClientRequest &getClientRequest();
+
+  /**
+   * Returns a Request object which is the request from Traffic Server to the origin server.
+   *
+   * @return Request object that can be used to manipulate the outgoing request to the origin server.
+   */
+  Request &getServerRequest();
+
+  /**
+   * Returns a Response object which is the response coming from the origin server
+   *
+   * @return Response object that can be used to manipulate the incoming response from the origin server.
+   */
+  Response &getServerResponse();
+
+  /**
+   * Returns a Response object which is the response going to the client
+   *
+   * @return Response object that can be used to manipulate the outgoing response from the client.
+   */
+  Response &getClientResponse();
+
+  /**
+   * Returns the Effective URL for this transaction taking into account host.
+   */
+  std::string getEffectiveUrl();
+
+  /**
+   * Sets the url used by the ATS cache for a specific transaction.
+   * @param url is the url to use in the cache.
+   */
+  bool setCacheUrl(const std::string &);
+
+  /**
+   * The available types of timeouts you can set on a Transaction.
+   */
+  enum TimeoutType {
+    TIMEOUT_DNS = 0, /**< Timeout on DNS */
+    TIMEOUT_CONNECT, /**< Timeout on Connect */
+    TIMEOUT_NO_ACTIVITY, /**< Timeout on No Activity */
+    TIMEOUT_ACTIVE /**< Timeout with Activity */
+  };
+
+  /**
+   * Allows you to set various types of timeouts on a Transaction
+   *
+   * @param type The type of timeout
+   * @param time_ms The timeout time in milliseconds
+   * @see TimeoutType
+   */
+  void setTimeout(TimeoutType type, int time_ms);
+
+  /**
+   * Returns the TSHttpTxn related to the current Transaction
+   *
+   * @return a void * which can be cast back to a TSHttpTxn.
+   */
+  void *getAtsHandle() const;
+
+  /**
+   * Adds a TransactionPlugin to the current Transaction. This effectively transfers ownership and the
+   * Transaction is now responsible for cleaning it up.
+   *
+   * @param TransactionPlugin* the TransactionPlugin that will be now bound to the current Transaction.
+   */
+  void addPlugin(TransactionPlugin *);
+
+private:
+  TransactionState *state_; //!< The internal TransactionState object tied to the current Transaction
+  friend class TransactionPlugin; //!< TransactionPlugin is a friend so it can call addPlugin()
+  friend class TransformationPlugin; //!< TransformationPlugin is a friend so it can call addPlugin()
+
+  /**
+   * @private
+   *
+   * @param raw_txn a void pointer that represents a TSHttpTxn
+   */
+  Transaction(void *);
+
+  /**
+   * Used to initialize the Request object for the Server.
+   *
+   * @private
+   */
+  void initServerRequest();
+
+  /**
+   * Used to initialize the Response object for the Server.
+   *
+   * @private
+   */
+  void initServerResponse();
+
+  /**
+   * Used to initialize the Response object for the Client.
+   *
+   * @private
+   */
+  void initClientResponse();
+
+  /**
+   * Returns a list of TransactionPlugin pointers bound to the current Transaction
+   *
+   * @private
+   *
+   * @return a std::list<TransactionPlugin *> which represents all TransactionPlugin bound to the current Transaction.
+   */
+  const std::list<TransactionPlugin *> &getPlugins() const;
+
+  friend class utils::internal;
+};
+
+} /* atscppapi */
+
+#endif /* ATSCPPAPI_TRANSACTION_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/TransactionPlugin.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/TransactionPlugin.h b/lib/atscppapi/src/include/atscppapi/TransactionPlugin.h
new file mode 100644
index 0000000..d473827
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/TransactionPlugin.h
@@ -0,0 +1,113 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+/**
+ * @file TransactionPlugin.h
+ * @brief Contains the interface used in creating Transaciton plugins.
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_TRANSACTIONPLUGIN_H_
+#define ATSCPPAPI_TRANSACTIONPLUGIN_H_
+
+#include <atscppapi/Plugin.h>
+#include <atscppapi/Transaction.h>
+#include <atscppapi/shared_ptr.h>
+#include <atscppapi/Mutex.h>
+
+namespace atscppapi {
+
+namespace utils {
+ class internal;
+} /* utils */
+
+/**
+ * @private
+ */
+class TransactionPluginState;
+
+/**
+ * @brief The interface used when creating a TransactionPlugin.
+ *
+ * A Transaction Plugin is a plugin that will fire only for the specific Transaction it
+ * was bound to. When you create a TransactionPlugin you call the parent constructor with
+ * the associated Transaction and it will become automatically bound. This means that your
+ * TransactionPlugin will automatically be destroyed when the Transaction dies.
+ *
+ * Implications of this are that you can easily add Transaction scoped storage by adding
+ * a member to a TransactionPlugin since the destructor will be called of your TransactionPlugin
+ * any cleanup that needs to happen can happen in your destructor as you normally would.
+ *
+ * You must always be sure to implement the appropriate callback for the type of hook you register.
+ *
+ * \code
+ * // For a more detailed example see examples/transactionhook/
+ * class TransactionHookPlugin : publicTransactionPlugin {
+ * public:
+ *   TransactionHookPlugin(Transaction &transaction) : TransactionPlugin(transaction) {
+ *     char_ptr_ = new char[100]; // Transaction scoped storage
+ *     registerHook(HOOK_SEND_RESPONSE_HEADERS);
+ *   }
+ *   virtual ~TransactionHookPlugin() {
+ *     delete[] char_ptr_; // cleanup
+ *   }
+ *   void handleSendResponseHeaders(Transaction &transaction) {
+ *     transaction.resume();
+ *   }
+ * private:
+ *   char *char_ptr_;
+ * };
+ * \endcode
+ *
+ * @see Plugin
+ * @see HookType
+ */
+class TransactionPlugin : public Plugin {
+public:
+  /**
+   * registerHook is the mechanism used to attach a transaction hook.
+   *
+   * \note Whenever you register a hook you must have the appropriate callback definied in your TransactionPlugin
+   *  see HookType and Plugin for the correspond HookTypes and callback methods. If you fail to implement the
+   *  callback, a default implmentation will be used that will only resume the Transaction.
+   *
+   * @param HookType the type of hook you wish to register
+   * @see HookType
+   * @see Plugin
+   */
+  void registerHook(Plugin::HookType hook_type);
+  virtual ~TransactionPlugin();
+protected:
+  TransactionPlugin(Transaction &transaction);
+
+  /**
+   * This method will return a shared_ptr to a Mutex that can be used for AsyncProvider and AsyncReceiver operations.
+   *
+   * If another thread wanted to stop this transaction from dispatching an event it could be passed
+   * this mutex and it would be able to lock it and prevent another thread from dispatching back into this
+   * TransactionPlugin.
+   */
+  shared_ptr<Mutex> getMutex();
+private:
+  TransactionPluginState *state_; /**< The internal state for a TransactionPlugin */
+  friend class utils::internal;
+};
+
+} /* atscppapi */
+
+
+#endif /* ATSCPPAPI_TRANSACTIONPLUGIN_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/TransformationPlugin.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/TransformationPlugin.h b/lib/atscppapi/src/include/atscppapi/TransformationPlugin.h
new file mode 100644
index 0000000..c4df942
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/TransformationPlugin.h
@@ -0,0 +1,129 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+/**
+ * @file TransformationPlugin.h
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_TRANSFORMATIONPLUGIN_H_
+#define ATSCPPAPI_TRANSFORMATIONPLUGIN_H_
+
+#include <string>
+#include <atscppapi/Transaction.h>
+#include <atscppapi/TransactionPlugin.h>
+
+namespace atscppapi {
+
+class TransformationPluginState;
+
+/**
+ * @brief The interface used when you wish to transform Request or Response body content.
+ *
+ * Transformations are deceptively simple, transformations are chained so the output
+ * of one TransformationPlugin becomes the input of another TransformationPlugin. As
+ * data arrives it will fire a consume() and when all the data has been sent
+ * you will receive a handleInputComplete(). Data can be sent to the next TransformationPlugin
+ * in the chain by calling produce() and when the transformation has no data left to send
+ * it will fire a setOutputCompete().
+ *
+ * Since a TransformationPlugin is a type of TransactionPlugin you can call registerHook() and
+ * establish any hook for a Transaction also; however, remember that you must implement
+ * the appropriate callback for any hooks you register.
+ *
+ * A simple example of how to use the TransformationPlugin interface follows, this is an example
+ * of a Response transformation, the avialable options are REQUEST_TRANSFORMATION and RESPONSE_TRANSFORMATION
+ * which are defined in Type.
+ *
+ * This example is a Null Transformation, meaning it will just spit out the content it receives without
+ * actually doing any work on it.
+ *
+ * \code
+ * class NullTransformationPlugin : public TransformationPlugin {
+ * public:
+ *   NullTransformationPlugin(Transaction &transaction)
+ *     : TransformationPlugin(transaction, RESPONSE_TRANSFORMATION) {
+ *     registerHook(HOOK_SEND_RESPONSE_HEADERS);
+ *   }
+ *   void handleSendResponseHeaders(Transaction &transaction) {
+ *     transaction.getClientResponse().getHeaders().set("X-Content-Transformed", "1");
+ *     transaction.resume();
+ *   }
+ *   void consume(const string &data) {
+ *     produce(data);
+ *   }
+ *   void handleInputComplete() {
+ *     setOutputComplete();
+ *   }
+ * };
+ * \endcode
+ *
+ * @see Plugin
+ * @see TransactionPlugin
+ * @see Type
+ * @see HookType
+ */
+class TransformationPlugin : public TransactionPlugin {
+public:
+  /**
+   * The available types of Transformations.
+   */
+  enum Type {
+    REQUEST_TRANSFORMATION = 0, /**< Transform the Request body content */
+    RESPONSE_TRANSFORMATION /**< Transform the Response body content */
+  };
+
+  /**
+   * A method that you must implement when writing a TransformationPlugin, this method will be
+   * fired whenever an upstream TransformationPlugin has produced output.
+   */
+  virtual void consume(const std::string &data) = 0;
+
+  /**
+   * A method that you must implement when writing a TransformationPlugin, this method
+   * will be fired whenever the upstream TransformationPlugin has completed writing data.
+   */
+  virtual void handleInputComplete() = 0;
+
+  virtual ~TransformationPlugin(); /**< Destructor for a TransformationPlugin */
+protected:
+
+  /**
+   * This method is how a TransformationPlugin will produce output for the downstream
+   * transformation plugin, if you need to produce binary data this can still be
+   * done with strings by a call to string::assign() or by constructing a string
+   * with string::string(char *, size_t).
+   */
+  size_t produce(const std::string &);
+
+  /**
+   * This is the method that you must call when you're done producing output for
+   * the downstream TranformationPlugin.
+   */
+  size_t setOutputComplete();
+
+  /** a TransformationPlugin must implement this interface, it cannot be constructed directly */
+  TransformationPlugin(Transaction &transaction, Type type);
+private:
+  TransformationPluginState *state_; /** Internal state for a TransformationPlugin */
+};
+
+} /* atscppapi */
+
+
+#endif /* ATSCPPAPI_TRANSFORMATIONPLUGIN_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7b2ea5f8/lib/atscppapi/src/include/atscppapi/Url.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Url.h b/lib/atscppapi/src/include/atscppapi/Url.h
new file mode 100644
index 0000000..e056d03
--- /dev/null
+++ b/lib/atscppapi/src/include/atscppapi/Url.h
@@ -0,0 +1,149 @@
+/**
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+/**
+ * @file Url.h
+ */
+
+#pragma once
+#ifndef ATSCPPAPI_URL_H_
+#define ATSCPPAPI_URL_H_
+
+#include <string>
+#include <stdint.h>
+#include <atscppapi/noncopyable.h>
+
+namespace atscppapi {
+
+class UrlState;
+
+/**
+ * @brief This class contains all properties of a Url.
+ *
+ * You can use a Url object to get and set any property of a url.
+ *
+ * @warning Url objects should never be constructed by the user.
+ * If a user needs to create an unbound Url then they should create a Request
+ * object using Request::Request(string) which will construct a Url object for them
+ * and it can be retrieved via Request::getUrl(). A full example of this
+ * is available in examples/detachedrequest/.
+ */
+class Url: noncopyable {
+public:
+  /**
+   * @warning Url objects should never be constructed by the user.
+   * If a user needs to create an unbound Url then they should create a Request
+   * object using Request::Request(string) which will construct a Url object for them
+   * and it can be retrieved via Request::getUrl(). A full example of this
+   * is available in examples/detachedrequest/.
+   *
+   * @private
+   */
+  Url();
+
+  /**
+   * @warning Url objects should never be constructed by the user.
+   * If a user needs to create an unbound Url then they should create a Request
+   * object using Request::Request(string) which will construct a Url object for them
+   * and it can be retrieved via Request::getUrl(). A full example of this
+   * is available in examples/detachedrequest/.
+   *
+   * @private
+   */
+  Url(void *hdr_buf, void *url_loc);
+  ~Url();
+
+  /**
+   * @return The full url as a string, such a url might be http://www.linkedin.com/profile/view?id=2941
+   */
+  const std::string &getUrlString() const;
+
+  /**
+   * @return The path only portion of the url, such as /profile/view
+   */
+  const std::string &getPath() const;
+
+  /**
+   * @return The query only portion of the url, which might be id=1234
+   */
+  const std::string &getQuery() const;
+
+  /**
+   * @return The scheme of the url, this will be either http or https.
+   */
+  const std::string &getScheme() const;
+
+  /**
+   * @return The host only of the url, this might be www.linkedin.com
+   */
+  const std::string &getHost() const;
+
+  /**
+   * @return The port only portion of the url, this will likely be 80 or 443.
+   */
+  uint16_t getPort() const;
+
+  /**
+   * Set the path of the url.
+   * @param path the path portion of the url to set, this might be something like /foo/bar
+   */
+  void setPath(const std::string &);
+
+  /**
+   * Set the query param of the url.
+   * @param query the query portion of the url, this might be something like foo=bar&blah=baz.
+   */
+  void setQuery(const std::string &);
+
+  /**
+   * Set the scheme of the url
+   * @param scheme this might be either http or https.
+   */
+  void setScheme(const std::string &);
+
+  /**
+   * Set the host of the url
+   * @param host this might be something such as www.linkedin.com or www.apache.org
+   */
+  void setHost(const std::string &);
+
+  /**
+   * Set the port portion of the url.
+   * @param port this is a uint16_t which represents the port (in host order, there is no need to conver to network order). You
+   * might use a value such as 80 or 8080.
+   */
+  void setPort(const uint16_t);
+
+  /**
+   * This method allows you to reset the url, this will force the Url to fully re-read all cached values.
+   * If this method is used on a Detached Requests' Url object it will completely destroy the values.
+   *
+   * \note This method should rarely be used.
+   */
+  void reset();
+private:
+  bool isInitialized() const;
+  void init(void *hdr_buf, void *url_loc);
+  UrlState *state_;
+  friend class Request;
+  friend class ClientRequest;
+  friend class RemapPlugin;
+};
+
+}
+
+#endif /* ATSCPPAPI_URL_H_ */