You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2017/03/08 00:30:31 UTC

[trafficserver] branch master updated: TS-4976: Regularize example plugin basic_auth.

This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  5d37cf6   TS-4976: Regularize example plugin basic_auth.
5d37cf6 is described below

commit 5d37cf628df1a90700757bbfc960e5b33a1d3bc9
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Sun Mar 5 08:28:40 2017 -0600

    TS-4976: Regularize example plugin basic_auth.
---
 .../basic-authorization/index.en.rst               |  3 +--
 .../plugins/example-plugins/index.en.rst           |  3 +--
 .../plugins/getting-started/index.en.rst           | 16 +++++++--------
 .../append-transform-plugin.en.rst                 | 12 +++++------
 doc/developer-guide/plugins/introduction.en.rst    |  2 +-
 example/Makefile.am                                |  4 ++--
 example/append_transform/readme.txt                | 10 ++++-----
 .../basic-auth.c => basic_auth/basic_auth.c}       | 24 ++++++++++++----------
 example/{basic-auth => basic_auth}/readme.txt      |  2 +-
 9 files changed, 37 insertions(+), 39 deletions(-)

diff --git a/doc/developer-guide/plugins/example-plugins/basic-authorization/index.en.rst b/doc/developer-guide/plugins/example-plugins/basic-authorization/index.en.rst
index 77a3abb..d80a576 100644
--- a/doc/developer-guide/plugins/example-plugins/basic-authorization/index.en.rst
+++ b/doc/developer-guide/plugins/example-plugins/basic-authorization/index.en.rst
@@ -22,7 +22,7 @@
 Basic Authorization Plugin
 **************************
 
-The sample basic authorization plugin, ``basic-auth.c``, checks for
+The sample basic authorization plugin, ``basic_auth.c``, checks for
 basic HTTP proxy authorization. In HTTP basic proxy authorization,
 client user names and passwords are contained in the
 ``Proxy-Authorization`` header. The password is encoded using base64
@@ -54,4 +54,3 @@ The parent continuation and global hook are created as follows:
    implementing-the-handler-and-getting-a-handle-to-the-transaction.en
    working-with-http-headers.en
    setting-a-transaction-hook.en
-
diff --git a/doc/developer-guide/plugins/example-plugins/index.en.rst b/doc/developer-guide/plugins/example-plugins/index.en.rst
index 4e120c4..5a573a5 100644
--- a/doc/developer-guide/plugins/example-plugins/index.en.rst
+++ b/doc/developer-guide/plugins/example-plugins/index.en.rst
@@ -47,7 +47,7 @@ understand the following topics:
 -  Working with HTTP header functions
 
 The two sample plugins discussed in this chapter are ``blacklist-1.c``
-and ``basic-auth.c``.
+and ``basic_auth.c``.
 
 Overview
 --------
@@ -75,4 +75,3 @@ following common elements:
 
 This chapter demonstrates how these components are implemented in SDK
 sample code.
-
diff --git a/doc/developer-guide/plugins/getting-started/index.en.rst b/doc/developer-guide/plugins/getting-started/index.en.rst
index 2ded690..2a52ae4 100644
--- a/doc/developer-guide/plugins/getting-started/index.en.rst
+++ b/doc/developer-guide/plugins/getting-started/index.en.rst
@@ -137,7 +137,7 @@ The figure below, :ref:`possibleTSplugins`, illustrates several types of plugins
 
 You can find basic examples for many plugins in the SDK sample code:
 
--  ``append-transform.c`` adds text from a specified file to HTTP/text
+-  ``append_transform.c`` adds text from a specified file to HTTP/text
    responses. This plugin is explained in
    :ref:`developer-plugins-http-transformations-append`
 
@@ -149,7 +149,7 @@ You can find basic examples for many plugins in the SDK sample code:
    ``server-transform.c``, a compression or image translation plugin
    could be implemented in a similar way.
 
--  ``basic-auth.c`` performs basic HTTP proxy authorization.
+-  ``basic_auth.c`` performs basic HTTP proxy authorization.
 
 -  ``blacklist-1.c`` reads blacklisted servers from a configuration file
    and denies client access to these servers. This plugin is explained
@@ -197,8 +197,8 @@ Plugins with global variables should not appear more than once in
 
 ::
 
-    add-header.so header1
-    add-header.so header2
+    add_header.so header1
+    add_header.so header2
 
 then the second global variable, ``header2``, will be used for both
 instances. A simple workaround is to give different names to different
@@ -206,15 +206,15 @@ instances of the same plugin. For example:
 
 ::
 
-    cp add-header.so add-header1.so
-    cp add-header.so add-header2.so
+    cp add_header.so add_header1.so
+    cp add_header.so add_header2.so
 
 These entries will produce the desired result below:
 
 ::
 
-    add-header1.so header1
-    add-header2.so header2
+    add_header1.so header1
+    add_header2.so header2
 
 Configuration File Rules
 ------------------------
diff --git a/doc/developer-guide/plugins/http-transformations/append-transform-plugin.en.rst b/doc/developer-guide/plugins/http-transformations/append-transform-plugin.en.rst
index 2207278..5494b44 100644
--- a/doc/developer-guide/plugins/http-transformations/append-transform-plugin.en.rst
+++ b/doc/developer-guide/plugins/http-transformations/append-transform-plugin.en.rst
@@ -19,23 +19,23 @@
 
 .. _developer-plugins-http-transformations-append:
 
-Append-Transform Plugin
+Append Transform Plugin
 ***********************
 
-The append-transform plugin appends text to the body of an HTTP
+The append_transform plugin appends text to the body of an HTTP
 response. It obtains this text from a file; the name of the file
 containing the append text is a parameter you specify in
 ``plugin.config``, as follows:
 
 ::
 
-    append-transform.so path/to/file
+    append_transform.so path/to/file
 
-The append-transform plugin is based on ``null-transform.c``. The only
+The append_transform plugin is based on ``null-transform.c``. The only
 difference is that after the plugin feeds the document through the
 transformation, it adds text to the response.
 
-Below is a list of the functions in ``append-transform.c``, in the order
+Below is a list of the functions in ``append_transform.c``, in the order
 they appear in the source code. Below each entry is a description of
 what the function does:
 
@@ -144,5 +144,3 @@ what the function does:
       ``TS_HTTP_READ_RESPONSE_HDR_HOOK``. In other words, it sets up a
       callback of the plugin's continuation when Traffic Server reads
       HTTP response headers.
-
-
diff --git a/doc/developer-guide/plugins/introduction.en.rst b/doc/developer-guide/plugins/introduction.en.rst
index 22f63ce..3b0d620 100644
--- a/doc/developer-guide/plugins/introduction.en.rst
+++ b/doc/developer-guide/plugins/introduction.en.rst
@@ -173,7 +173,7 @@ them into activity.
 
 A plugin may consist of just one static continuation that is called
 whenever certain events happen. Examples of such plugins include
-``blacklist-1.c``, ``basic-auth.c``, and ``redirect-1.c``.
+``blacklist-1.c``, ``basic_auth.c``, and ``redirect-1.c``.
 Alternatively, a plugin might dynamically create other continuations as
 needed. Transform plugins are built in this manner: a static parent
 continuation checks all transactions to see if any are transformable;
diff --git a/example/Makefile.am b/example/Makefile.am
index 916540d..c26a9f9 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -25,7 +25,7 @@ libatscppai = $(top_builddir)/lib/cppapi/libatscppapi.la
 example_Plugins = \
 	add_header.la \
 	append_transform.la \
-	basic-auth.la \
+	basic_auth.la \
 	blacklist-0.la \
 	blacklist-1.la \
 	bnull-transform.la \
@@ -89,7 +89,7 @@ endif
 
 add_header_la_SOURCES = add_header/add_header.c
 append_transform_la_SOURCES = append_transform/append_transform.c
-basic_auth_la_SOURCES = basic-auth/basic-auth.c
+basic_auth_la_SOURCES = basic_auth/basic_auth.c
 blacklist_0_la_SOURCES = blacklist-0/blacklist-0.c
 blacklist_1_la_SOURCES = blacklist-1/blacklist-1.c
 bnull_transform_la_SOURCES = bnull-transform/bnull-transform.c
diff --git a/example/append_transform/readme.txt b/example/append_transform/readme.txt
index 379c3a8..4eff0f2 100644
--- a/example/append_transform/readme.txt
+++ b/example/append_transform/readme.txt
@@ -1,6 +1,6 @@
-About append-transform.c
+About append_transform.c
 
-This example is based on null-transform.c. It appends text to the body
+This example is based on null_transform.c. It appends text to the body
 of an HTML text response document on its way from the cache to the
 client.
 
@@ -8,13 +8,13 @@ The plugin first makes sure that it has received a "200 OK"
 response from the origin server.  It then verifies that the returned
 document is of type "text/html".  It "transforms" the document by
 appending text to the file.   To read and write to the body of the
-document, the plugin uses functions similar to those in null-transform.c.
+document, the plugin uses functions similar to those in null_transform.c.
 
 You place the text to be appended in a file, and you must provide the
 path to the file in plugin.config. In other words, plugin.config must
 have a line similar to the following:
 
-  append-transform.so path/to/file
+  append_transform.so path/to/file
 
 Specify an absolute path to the text file, or a relative path as
 described in the file-plugin README.
@@ -83,6 +83,6 @@ The transform_add function does the following:
 
 The remaining functions in the plugin, append_transform and
 handle_transform, are similar to null_transform and
-handle_transform in the null-transform.c plugin.
+handle_transform in the null_transform.c plugin.
 
 
diff --git a/example/basic-auth/basic-auth.c b/example/basic_auth/basic_auth.c
similarity index 88%
rename from example/basic-auth/basic-auth.c
rename to example/basic_auth/basic_auth.c
index 4d4aa31..8c16ac3 100644
--- a/example/basic-auth/basic-auth.c
+++ b/example/basic_auth/basic_auth.c
@@ -29,6 +29,8 @@
 #include "ts/ts.h"
 #include "ts/ink_defs.h"
 
+#define PLUGIN_NAME "basic_auth"
+
 static char base64_codes[256];
 
 static char *
@@ -95,20 +97,20 @@ handle_dns(TSHttpTxn txnp, TSCont contp)
   int authval_length;
 
   if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
-    TSError("[basic_auth] Couldn't retrieve client request header");
+    TSError("[%s] Couldn't retrieve client request header", PLUGIN_NAME);
     goto done;
   }
 
   field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_PROXY_AUTHORIZATION, TS_MIME_LEN_PROXY_AUTHORIZATION);
   if (!field_loc) {
     TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
-    TSError("[basic_auth] No Proxy-Authorization field");
+    TSError("[%s] No Proxy-Authorization field", PLUGIN_NAME);
     goto done;
   }
 
   val = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &authval_length);
   if (NULL == val) {
-    TSError("[basic_auth] No value in Proxy-Authorization field");
+    TSError("[%s] No value in Proxy-Authorization field", PLUGIN_NAME);
     TSHandleMLocRelease(bufp, hdr_loc, field_loc);
     TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     goto done;
@@ -116,7 +118,7 @@ handle_dns(TSHttpTxn txnp, TSCont contp)
 
   ptr = val;
   if (strncmp(ptr, "Basic", 5) != 0) {
-    TSError("[basic_auth] No Basic auth type in Proxy-Authorization");
+    TSError("[%s] No Basic auth type in Proxy-Authorization", PLUGIN_NAME);
     TSHandleMLocRelease(bufp, hdr_loc, field_loc);
     TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     goto done;
@@ -130,7 +132,7 @@ handle_dns(TSHttpTxn txnp, TSCont contp)
   user     = base64_decode(ptr);
   password = strchr(user, ':');
   if (!password) {
-    TSError("[basic_auth] No password in authorization information");
+    TSError("[%s] No password in authorization information", PLUGIN_NAME);
     TSfree(user);
     TSHandleMLocRelease(bufp, hdr_loc, field_loc);
     TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
@@ -140,7 +142,7 @@ handle_dns(TSHttpTxn txnp, TSCont contp)
   password += 1;
 
   if (!authorized(user, password)) {
-    TSError("[basic_auth] %s:%s not authorized", user, password);
+    TSError("[%s] %s:%s not authorized", PLUGIN_NAME, user, password);
     TSfree(user);
     TSHandleMLocRelease(bufp, hdr_loc, field_loc);
     TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
@@ -168,7 +170,7 @@ handle_response(TSHttpTxn txnp)
   int len            = strlen(insert);
 
   if (TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
-    TSError("[basic_auth] Couldn't retrieve client response header");
+    TSError("[%s] Couldn't retrieve client response header", PLUGIN_NAME);
     goto done;
   }
 
@@ -213,12 +215,12 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
   int i, cc;
   TSPluginRegistrationInfo info;
 
-  info.plugin_name   = "basic-authorization";
-  info.vendor_name   = "MyCompany";
-  info.support_email = "ts-api-support@MyCompany.com";
+  info.plugin_name   = PLUGIN_NAME;
+  info.vendor_name   = "Apache Software Foundation";
+  info.support_email = "dev@trafficserver.apache.org";
 
   if (TSPluginRegister(&info) != TS_SUCCESS) {
-    TSError("[basic_auth] Plugin registration failed.");
+    TSError("[%s] Plugin registration failed.", PLUGIN_NAME);
   }
 
   /* Build translation table */
diff --git a/example/basic-auth/readme.txt b/example/basic_auth/readme.txt
similarity index 97%
rename from example/basic-auth/readme.txt
rename to example/basic_auth/readme.txt
index 096fe12..fbbdf05 100644
--- a/example/basic-auth/readme.txt
+++ b/example/basic_auth/readme.txt
@@ -1,4 +1,4 @@
-The basic-auth.c plugin performs basic HTTP proxy authentication.
+The basic_auth.c plugin performs basic HTTP proxy authentication.
 
 -- The plugin checks all client request headers for the Proxy-Authorization
    MIME field, which should contain the user name and password.

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].