You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by di...@apache.org on 2010/03/23 22:20:23 UTC

svn commit: r926787 - in /incubator/trafficserver/site/trunk/docs/v2/sdk: HeaderBasedPluginEx.html ch03.html ch03s02.html ch03s03.html ch03s04.html

Author: dianes
Date: Tue Mar 23 21:20:22 2010
New Revision: 926787

URL: http://svn.apache.org/viewvc?rev=926787&view=rev
Log:
working on TS-270....

Modified:
    incubator/trafficserver/site/trunk/docs/v2/sdk/HeaderBasedPluginEx.html
    incubator/trafficserver/site/trunk/docs/v2/sdk/ch03.html
    incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s02.html
    incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s03.html
    incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s04.html

Modified: incubator/trafficserver/site/trunk/docs/v2/sdk/HeaderBasedPluginEx.html
URL: http://svn.apache.org/viewvc/incubator/trafficserver/site/trunk/docs/v2/sdk/HeaderBasedPluginEx.html?rev=926787&r1=926786&r2=926787&view=diff
==============================================================================
--- incubator/trafficserver/site/trunk/docs/v2/sdk/HeaderBasedPluginEx.html (original)
+++ incubator/trafficserver/site/trunk/docs/v2/sdk/HeaderBasedPluginEx.html Tue Mar 23 21:20:22 2010
@@ -3,9 +3,9 @@
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Chapter 4. Header-Based Plugin Examples</title>
 <!--#include file="top.html" -->
-<div class="navheader">
+</head><div class="navheader">
 <div class="navprev">
-<a accesskey="p" href="ch03s04.html">Prev</a> — Examples</div>
+<a accesskey="p" href="ch03s02.html">Prev</a> — API Function Reference</div>
 <div class="navnext">The Blacklist Plugin — <a accesskey="n" href="BlacklistPlugin.html">Next</a>
 </div>
 </div>

Modified: incubator/trafficserver/site/trunk/docs/v2/sdk/ch03.html
URL: http://svn.apache.org/viewvc/incubator/trafficserver/site/trunk/docs/v2/sdk/ch03.html?rev=926787&r1=926786&r2=926787&view=diff
==============================================================================
--- incubator/trafficserver/site/trunk/docs/v2/sdk/ch03.html (original)
+++ incubator/trafficserver/site/trunk/docs/v2/sdk/ch03.html Tue Mar 23 21:20:22 2010
@@ -6,7 +6,7 @@
 </head><div class="navheader">
 <div class="navprev">
 <a accesskey="p" href="Roadmap_CreatingPlugins.html">Prev</a> — Roadmap for Creating Plugins</div>
-<div class="navnext">Remap.API.h — <a accesskey="n" href="ch03s02.html">Next</a>
+<div class="navnext">API Function Reference — <a accesskey="n" href="ch03s02.html">Next</a>
 </div>
 </div>
 <div id="toc"></div>
@@ -16,27 +16,46 @@
 
 <p><b>Table of Contents</b></p>
 <ul>
-<li><span class="section"><a href="ch03.html#id372652">Why Use a Remap Plugin?</a></span></li>
-<li><span class="section"><a href="ch03s02.html">Remap.API.h</a></span></li>
-<li><span class="section"><a href="ch03s03.html">Functions You Need to Implement</a></span></li>
-<li><span class="section"><a href="ch03s04.html">Examples</a></span></li>
+<li><span class="section"><a href="ch03.html#GettingStarted">Getting Started</a></span></li>
+<ul><li><a href="ch03.html#RemapHeaderFile">Remap Header File </a></li>
+<li><a href="ch03.html#RequiredFunctions">Required Functions </a></li>
+<li><a href="ch03.html#Configuration">Configuration </a></li>
 </ul>
-<div> </div>
-<p>((Editor's note: additional text TBD; text below still under development))</p>
-<p>&nbsp;</p>
-<p>The remap plugin provides a more flexible, dynamic way of specifying
-    remap rules. It is not built on top of the <code class="code">INK_</code> APIs, and
+<li><span class="section"><a href="ch03s02.html">API Function Reference</a></span></li>
+</ul>
+<div></div>
+<p>The Remap plugin provides a more flexible, dynamic way of specifying
+    remap rules. It is not built on top of the Traffic Server APIs and
     exists solely for the purpose of URL remapping. The remap plugin is not
     global --it is configured on a per-remap rule basis, which enables you to customize
-    how URLs are redirected based on individual rules in the
-    <code class="filename">remap.config</code> file.</p>
+  how URLs are redirected based on individual rules in the <code class="filename">remap.config</code> file.</p>
+<p>The Traffic Server Remap API enables a plugin to dynamically map a client request to a target URL. Each plugin is associated with one or more remap rules in <code class="filename">remap.config</code> (an &quot;instance&quot;). If a request URL matches a remap rule's "fromURL", then Traffic Server  calls the plugin-defined remap function for that request.</p>
+<p>&nbsp;</p>
+<p>((Editor's note: additional text TBD; text in this chapter is still under development))</p>
 <div class="section" lang="en">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="id372652"></a>Why Use a Remap Plugin?</h2></div></div></div>
-<p>As described in section ((need URL here)), Traffic Server uses the rules
-      contained in <code class="filename">remap.config</code> to redirect URLs. When
-      you write and/or use a remap plugin, you modify those static rules by
-      attaching a piece of code to each rule. For example:</p>
+  <div class="titlepage"><div><div>
+    <h2 class="title" style="clear: both">
+  <a name="GettingStarted"></a>Getting Started</h2></div></div></div>
+  <h3><a name="RemapHeaderFile">Remap Header File </a> </h3>
+<p>The <code class="filename"> remap.h</code> header file contains the Traffic Server remap API.  By default, the header file location  is: <code class="filename">/usr/local/include/ts/remap.h</code></p>
+  <p>&nbsp;</p>
+      <h3><a name="RequiredFunctions">Required Functions </a></h3>
+  <p>A remap plugin is required to implement the following functions: 
+    <ul>
+      
+      <li><code><b>tsremap_init</b></code> (TODO link): the remap initialization function</li>
+      <li><code><b>tsremap_new_instance</b></code> (TODO link):  anew instance is created for each rule associated with the plugin</li>
+      <li><code><b>tsremap_remap</b></code> (TODO link): the main remap function</li>
+    </ul> </p>
+  
+  <h3><a name="Configuration">Configuration </a></h3>
+          <p>To associate a remap plugin with a remap rule, use the <code>@pplugin</code> parameter. See the Admin Guide section (?TBD?) for details on configuring remap plugins</p>
+  
+  
+</div>
+      
+      </ul>
+       </p>
 </div>
 </div>
 </body>

Modified: incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s02.html
URL: http://svn.apache.org/viewvc/incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s02.html?rev=926787&r1=926786&r2=926787&view=diff
==============================================================================
--- incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s02.html (original)
+++ incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s02.html Tue Mar 23 21:20:22 2010
@@ -3,22 +3,140 @@
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Remap.API.h</title>
 <!--#include file="top.html" -->
-<div class="navheader">
+</head><div class="navheader">
 <div class="navprev">
-<a accesskey="p" href="ch03.html">Prev</a> — Chapter 3. Remap Plugin</div>
-<div class="navnext">Functions You Need to Implement — <a accesskey="n" href="ch03s03.html">Next</a>
+<a accesskey="p" href="ch03.html">Prev</a> — Chapter 3. Remap Plugin: Getting Started</div>
+<div class="navnext">Chapter 4: Header-Based Plugin Examples— <a accesskey="n" href="HeaderBasedPluginEx.html">Next</a>
 </div>
 </div>
 <div id="toc"></div>
 <div class="section" lang="en">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="id372670"></a>Remap.API.h</h2></div></div></div>
-<p>((Editor's note: text TBD; below text still under development))</p>
-<p>The <code class="filename">RemapAPI.h</code> include file is
-      ...........</p>
-<p>&nbsp;</p>
-<p>Explain the APIs --&gt; how plugin gets data from the request
-      --&gt; how plugin rewrites/modifies the request</p>
+<div class="titlepage"><div><div>
+  <h2 class="title" style="clear: both">
+<a name="id372670"></a>API Function Reference  </h2>
+  <ul>
+  <li><a href=ch03s02.html#tsremap_init>tsremap_init </a> </li>
+  <li><a href=ch03s02.html#tsremap_new_instance>tsremap_new_instance </a> </li>
+  <li><a href=ch03s02.html#tsremap_remap>tsremap_remap </a> </li>
+  <li><a href=ch03s02.html#tsremap_delete_instance>tsremap_delete_instance </a> </li>
+  <li><a href=ch03s02.html#tsremap_os_response>tsremap_os_response </a> </li>
+  </ul>
+  </p>
+</div></div></div>
+<h4 class="title"><a name="tsremap_init"></a>tsremap_init</h4>
+<p>The remap plugin initialization function.</p>
+<div class="variablelist">
+  <dl>
+    <dt><span class="term"><b>Prototype</b></span></dt>
+    <dd>
+      <p><code class="code">int tsremap_init(TSRemapInterface * <span class="replaceable">api_info</span>, char *<span class="replaceable">errbuf</span>, int <span class="replaceable">errbuf_size</span>);</code></p>
+    </dd>
+    <dt><span class="term"><b>Arguments</b></span></dt>
+    <dd>
+      <p><code class="code"><em class="replaceable">api_info </em></code> is a <code class="code">TSRemapInterface</code> struct containing remap API interface version information</p>
+      <p><code class="code"><em class="replaceable">errbuf </em></code> is a buffer in which the plugin may write informational error messages about initialization errors.</p>
+      <p><code class="code"><em class="replaceable">errbuf_size </em></code> is the size, in bytes, of the buffer pointed to by <code class="code">errbuf</code></p>
+    </dd>
+    <dt><span class="term"><b>Description</b></span></dt>
+    <dd>
+      <p>Traffic Server calls this initialization routine once per remap plugin. All remap plugins are required to implement this function.</p>
+    </dd>
+    <dt><span class="term"><b>Returns</b></span></dt>
+    <dd>
+      <p>The function must return <code class="code">0</code> upon successful plugin initialization.</p>
+    </dd>
+  </dl>
+</div>
+<h4 class="title"><a name="tsremap_new_instance"></a>tsremap_new_instance</h4>
+<p>The remap instance initialization function.</p>
+<div class="variablelist">
+  <dl>
+    <dt><span class="term"><b>Prototype</b></span></dt>
+    <dd>
+      <p><code class="code">int tsremap_new_instance(int argc, char *argv[], ihandle * <span class="replaceable">ih</span>, char *<span class="replaceable">errbuf</span>, int <span class="replaceable">errbuf_size</span>);</code></p>
+    </dd>
+    <dt><span class="term"><b>Arguments</b></span></dt>
+    <dd>
+      <p><code class="code"><em class="replaceable">argc </em></code> is a count of the number of arguments in the argument vector, argv.</p>
+      <p><code class="code"><em class="replaceable">argv </em></code> is the vector of arguments. The number of arguments in the vector is <code class="code">argc</code>. <code class="code">argv[0]</code> and <code class="code">argv[1] </code> contain the <code class="code">fromURL</code> and <code class="code">toURL</code>, respectively, from the remap rule in canonical form. Additional plugin parameters may be passed to the plugin using <code class="code">@pparam=plugin_name</code> in the configuration file.</p>
+      <p>The <code class="code"><em class="replaceable">ih, </em></code> or <code class="code">ihandle</code>, is a opaque pointer that can be used by the plugin to store per-instance data.  Traffic Server  passes this handle to <code class="code">tsremap_remap</code>, <code class="code">tsremap_os_response</code>, and <code class="code">tsremap_delete_instance</code> for operations on this instance.  If memory is allocated for the ihandle, then it can be freed via <code class="code">tsremap_delete_instance</code>.</p>
+      <p><code class="code"><em class="replaceable">errbuf </em></code> is a  buffer in which the plugin may write informational error messages about instance initialization errors.</p>
+      <p><code class="code"><em class="replaceable">errbuf_size </em></code> is the size, in bytes, of the buffer pointed to by <code class="replaceable">errbuf</code>.</p>
+    </dd>
+    <dt><span class="term"><b>Description</b></span></dt>
+    <dd>
+      <p>Traffic Server calls this initialization routine once per remap instance for which the plugin is configured (i.e. once per rule in remap.config that has <code class="code">@pplugin=</code>).  All remap plugins are required to implement this function.</p>
+    </dd>
+    <dt><span class="term"><b>Returns</b></span></dt>
+    <dd>
+      <p>The function must return <code class="code">0</code> on successful instance initialization.</p>
+    </dd>
+  </dl>
+</div>
+<h4 class="title"><a name="tsremap_remap"></a>tsremap_remap</h4>
+<p>Remap request function.</p>
+<div class="variablelist">
+  <dl>
+    <dt><span class="term"><b>Prototype</b></span></dt>
+    <dd>
+      <p><code class="code">int tsremap_remap(ihandle <span class="replaceable">ih</span>, rhandle <span class="replaceable">rh</span>, TSRemapRequestInfo * <span class="replaceable">rri</span>)</code></p>
+    </dd>
+    <dt><span class="term"><b>Arguments</b></span></dt>
+    <dd>
+      <p><code class="code"><em class="replaceable">ih </em></code> is the ihandle for the instance set during tsremap_new_instance</p>
+      <p><code class="code"><em class="replaceable">rh</em></code> is the INKHttpTxn for the request.  This allows remap plugins to use APIs from ts.h</p>
+      <p><code class="code"><em class="replaceable">rri</em></code> The TSRemapRequestInfo struct contains input and output parameters for the remap operation for a single request. The struct members are as follows:</p>
+      <h5 class="title">Input (read-only) members</h5>
+      <pre class="programlisting">    unsigned long size;          /* sizeof(TSRemapRequestInfo) */      int request_port;            /* request port number */     int remap_from_port;         /* fromURL port number (from remap rule string) */     int remap_to_port;           /* toURL port number (from remap rule string) */      const char *orig_url;        /* request URL (not NULL terminated) */     int orig_url_size;           /* request URL size */      const char *request_host;    /* request host string (not NULL terminated) */     int request_host_size;       /* request host string size */      const char *remap_from_host; /* fromURL host (from remap rule string) */     int remap_from_host_size;    /* fromURL host size */      const char *remap_to_host;   /* toURL host (from remap rule string) */     int remap_to_host_size;      /* toURL host size */      const char *request_path;    /* request path (not NULL terminated) */     int request_path_size;       /* request pa
 th size */      const char *remap_from_path; /* fromURL path (from remap rule string) */     int remap_from_path_size;    /* fromURL path size */      const char *remap_to_path;   /* toURL path (from remap rule string) */     int remap_to_path_size;      /* toURL path size */      const char *request_cookie;  /* request cookie string (not NULL terminated) */     int request_cookie_size;     /* request cookie string size */      const char *request_query;   /* request query string (not NULL terminated) */     int request_query_size;      /* request query string size. */      const char *request_matrix;  /* request matrix string (not NULL terminated) */     int request_matrix_size;     /* request matrix string size. */      const char *from_scheme;    /* The "from" scheme (e.g. http) */     int from_scheme_len;        /* The len of the "from" scheme */      const char *to_scheme;      /* The "to" scheme (e.g. http) */     int to_scheme_len;          /* The len of the "to" sche
 me */      unsigned int client_ip;     /* The client IP is an unsigned network order (big-endian) 32-bit number. */ </pre>
+      <h5 class="title">Output members</h5>
+      <pre class="programlisting">    char new_host[TSREMAP_RRI_MAX_HOST_SIZE];   /* new host string */     int new_host_size;                          /* new host string size (if 0 - do not change request host) */     int new_port;                               /* new port number (0 - do not change request port) */     char new_path[TSREMAP_RRI_MAX_PATH_SIZE];   /* new path string */     int new_path_size;                          /* new path string size (0 - do not change request path) */     char new_query[TSREMAP_RRI_MAX_PATH_SIZE];  /* new query string */     int new_query_size;                         /* new query string size (0 - do not change request query) */     char new_matrix[TSREMAP_RRI_MAX_PATH_SIZE]; /* new matrix parameter string */     int new_matrix_size;                        /* new matrix parameter string size (0 - do not change matrix parameters) */     char redirect_url[TSREMAP_RRI_MAX_REDIRECT_URL];    /* redirect url (to redirect/reject request) */  
    int redirect_url_size;                      /* redirect url size (0 - empty redirect url string) */     int require_ssl;                            /* Require the toScheme to become SSL (e.g. HTTPS).  */                                                 /*    0 -&gt; Disable SSL if toScheme is SSL */                                                 /*    1 -&gt; Enable SSL if toScheme is not SSL */                                                 /*   -1 (default) -&gt; Don't modify scheme */ </pre>
+    </dd>
+    <dt><span class="term"><b>Returns</b></span></dt>
+    <dd>
+      <p>A non-zero return value indicates that the plugin modified the output members of the <code class="code">rri</code> argument. TS will use those values to modify the client request.  Otherwise, the plugin can return <code class="code">0</code> to indicate that TS should use the default <code class="code">toURL</code> from the remap rule.</p>
+    </dd>
+    <dt><span class="term"><b>Description</b></span></dt>
+    <dd>
+      <p>This is the main remap function in which the plugin can modify the client request based on the rri input members. The function is called for client requests for which the remap rule associated with the plugin matches (based on <code class="code">fromURL</code>). Note that if multiple rules match the client request, Traffic Server uses the first match. In relation to Traffic Server's HTTP transaction APIs, <code class="code">tsremap_remap</code> is invoked before <code class="code">INK_HTTP_READ_REQUEST_HDR_HOOK</code> and before cache lookup.  Thus, if the plugin modifies the request, then the cache lookup key will be altered.</p>
+    </dd>
+  </dl>
+</div>
+<h4 class="title"><a name="tsremap_delete_instance"></a>tsremap_delete_instance</h4>
+<div class="variablelist">
+  <dl>
+    <dt><span class="term"><b>Prototype</b></span></dt>
+    <dd>
+      <p><code class="code">void tsremap_delete_instance(ihandle <span class="replaceable">ih</span>)</code></p>
+    </dd>
+    <dt><span class="term"><b>Arguments</b></span></dt>
+    <dd>
+      <p><code class="code"><em class="replaceable">ih </em></code> is the ihandle for the instance set during <code>tsremap_new_instance</code>.</p>
+    </dd>
+    <dt><span class="term"><b>Description</b></span></dt>
+    <dd>
+      <p>The plugin can optionally define this function, which will be called when a remap instance is released. For example when <code>remap.config</code> is reloaded, all existing instances are released and new instances are created.</p>
+    </dd>
+  </dl>
+</div>
+<h4 class="title"><a name="tsremap_os_response"></a>tsremap_os_response</h4>
+<div class="variablelist">
+  <dl>
+    <dt><span class="term"><b>Prototype</b></span></dt>
+    <dd>
+      <p><code class="code">void tsremap_os_response(ihandle <span class="replaceable">ih</span>, rhandle <span class="replaceable">rh</span>, int <span class="replaceable">os_response_type</span>)</code></p>
+    </dd>
+    <dt><span class="term"><b>Arguments</b></span></dt>
+    <dd>
+      <p><code class="code"><em class="replaceable">ih </em></code> is the ihandle for the instance set during <code>tsremap_new_instance</code>.</p>
+      <p><code class="code"><em class="replaceable">rh </em></code> is the <code>INKHttpTxn</code> for the request.  It enables  remap plugins to use APIs from <code>ts.h</code></p>
+      <p><code class="code"><em class="replaceable">os_response_type </em></code> is a value of <code>INKServerState</code> that indicates the state of the response.</p>
+    </dd>
+    <dt><span class="term"><b>Description</b></span></dt>
+    <dd>
+      <p>This optional function is called after Traffic Server receives a response from the origin server. If the request is served from cache, then the function is not called .</p>
+    </dd>
+  </dl>
+</div>
 <p>&nbsp;</p>
 </div>
 </body>

Modified: incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s03.html
URL: http://svn.apache.org/viewvc/incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s03.html?rev=926787&r1=926786&r2=926787&view=diff
==============================================================================
--- incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s03.html (original)
+++ incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s03.html Tue Mar 23 21:20:22 2010
@@ -3,7 +3,7 @@
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Functions You Need to Implement</title>
 <!--#include file="top.html" -->
-<div class="navheader">
+</head><div class="navheader">
 <div class="navprev">
 <a accesskey="p" href="ch03s02.html">Prev</a> — Remap.API.h</div>
 <div class="navnext">Examples — <a accesskey="n" href="ch03s04.html">Next</a>

Modified: incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s04.html
URL: http://svn.apache.org/viewvc/incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s04.html?rev=926787&r1=926786&r2=926787&view=diff
==============================================================================
--- incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s04.html (original)
+++ incubator/trafficserver/site/trunk/docs/v2/sdk/ch03s04.html Tue Mar 23 21:20:22 2010
@@ -3,7 +3,7 @@
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Examples</title>
 <!--#include file="top.html" -->
-<div class="navheader">
+</head><div class="navheader">
 <div class="navprev">
 <a accesskey="p" href="ch03s03.html">Prev</a> — Functions You Need to Implement</div>
 <div class="navnext">Chapter 4. Header-Based Plugin Examples — <a accesskey="n" href="HeaderBasedPluginEx.html">Next</a>