trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kic...@apache.org
Subject [2/3] TS:2716 fix indentation for ts_lua plugin
Date Sun, 11 May 2014 20:40:19 GMT
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_http.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_http.c b/plugins/experimental/ts_lua/ts_lua_http.c
index ba28364..599cd80 100644
--- a/plugins/experimental/ts_lua/ts_lua_http.c
+++ b/plugins/experimental/ts_lua/ts_lua_http.c
@@ -20,208 +20,208 @@
 #include "ts_lua_util.h"
 #include "ts_lua_http_intercept.h"
 
-typedef enum {
-    TS_LUA_CACHE_LOOKUP_MISS,
-    TS_LUA_CACHE_LOOKUP_HIT_STALE,
-    TS_LUA_CACHE_LOOKUP_HIT_FRESH,
-    TS_LUA_CACHE_LOOKUP_SKIPPED
+typedef enum
+{
+  TS_LUA_CACHE_LOOKUP_MISS,
+  TS_LUA_CACHE_LOOKUP_HIT_STALE,
+  TS_LUA_CACHE_LOOKUP_HIT_FRESH,
+  TS_LUA_CACHE_LOOKUP_SKIPPED
 } TSLuaCacheLookupResult;
 
-char * ts_lua_cache_lookup_result_string[] = {
-    "TS_LUA_CACHE_LOOKUP_MISS",
-    "TS_LUA_CACHE_LOOKUP_HIT_STALE",
-    "TS_LUA_CACHE_LOOKUP_HIT_FRESH",
-    "TS_LUA_CACHE_LOOKUP_SKIPPED"
+char *ts_lua_cache_lookup_result_string[] = {
+  "TS_LUA_CACHE_LOOKUP_MISS",
+  "TS_LUA_CACHE_LOOKUP_HIT_STALE",
+  "TS_LUA_CACHE_LOOKUP_HIT_FRESH",
+  "TS_LUA_CACHE_LOOKUP_SKIPPED"
 };
 
-static void ts_lua_inject_http_retset_api(lua_State *L);
-static void ts_lua_inject_http_cache_api(lua_State *L);
-static void ts_lua_inject_http_transform_api(lua_State *L);
+static void ts_lua_inject_http_retset_api(lua_State * L);
+static void ts_lua_inject_http_cache_api(lua_State * L);
+static void ts_lua_inject_http_transform_api(lua_State * L);
 
-static int ts_lua_http_set_retstatus(lua_State *L);
-static int ts_lua_http_set_retbody(lua_State *L);
-static int ts_lua_http_set_resp(lua_State *L);
+static int ts_lua_http_set_retstatus(lua_State * L);
+static int ts_lua_http_set_retbody(lua_State * L);
+static int ts_lua_http_set_resp(lua_State * L);
 
-static int ts_lua_http_get_cache_lookup_status(lua_State *L);
-static int ts_lua_http_set_cache_url(lua_State *L);
-static void ts_lua_inject_cache_lookup_result_variables(lua_State *L);
+static int ts_lua_http_get_cache_lookup_status(lua_State * L);
+static int ts_lua_http_set_cache_url(lua_State * L);
+static void ts_lua_inject_cache_lookup_result_variables(lua_State * L);
 
-static int ts_lua_http_resp_cache_transformed(lua_State *L);
-static int ts_lua_http_resp_cache_untransformed(lua_State *L);
+static int ts_lua_http_resp_cache_transformed(lua_State * L);
+static int ts_lua_http_resp_cache_untransformed(lua_State * L);
 
 void
-ts_lua_inject_http_api(lua_State *L)
+ts_lua_inject_http_api(lua_State * L)
 {
-    lua_newtable(L);
+  lua_newtable(L);
 
-    ts_lua_inject_http_retset_api(L);
-    ts_lua_inject_http_cache_api(L);
-    ts_lua_inject_http_transform_api(L);
-    ts_lua_inject_http_intercept_api(L);
+  ts_lua_inject_http_retset_api(L);
+  ts_lua_inject_http_cache_api(L);
+  ts_lua_inject_http_transform_api(L);
+  ts_lua_inject_http_intercept_api(L);
 
-    lua_setfield(L, -2, "http");
+  lua_setfield(L, -2, "http");
 }
 
 static void
-ts_lua_inject_http_retset_api(lua_State *L)
+ts_lua_inject_http_retset_api(lua_State * L)
 {
-    lua_pushcfunction(L, ts_lua_http_set_retstatus);
-    lua_setfield(L, -2, "set_retstatus");
+  lua_pushcfunction(L, ts_lua_http_set_retstatus);
+  lua_setfield(L, -2, "set_retstatus");
 
-    lua_pushcfunction(L, ts_lua_http_set_retbody);
-    lua_setfield(L, -2, "set_retbody");
+  lua_pushcfunction(L, ts_lua_http_set_retbody);
+  lua_setfield(L, -2, "set_retbody");
 
-    lua_pushcfunction(L, ts_lua_http_set_resp);
-    lua_setfield(L, -2, "set_resp");
+  lua_pushcfunction(L, ts_lua_http_set_resp);
+  lua_setfield(L, -2, "set_resp");
 }
 
 static void
-ts_lua_inject_http_cache_api(lua_State *L)
+ts_lua_inject_http_cache_api(lua_State * L)
 {
-    lua_pushcfunction(L, ts_lua_http_get_cache_lookup_status);
-    lua_setfield(L, -2, "get_cache_lookup_status");
+  lua_pushcfunction(L, ts_lua_http_get_cache_lookup_status);
+  lua_setfield(L, -2, "get_cache_lookup_status");
 
-    lua_pushcfunction(L, ts_lua_http_set_cache_url);
-    lua_setfield(L, -2, "set_cache_url");
+  lua_pushcfunction(L, ts_lua_http_set_cache_url);
+  lua_setfield(L, -2, "set_cache_url");
 
-    ts_lua_inject_cache_lookup_result_variables(L);
+  ts_lua_inject_cache_lookup_result_variables(L);
 }
 
 static void
-ts_lua_inject_http_transform_api(lua_State *L)
+ts_lua_inject_http_transform_api(lua_State * L)
 {
-    lua_pushcfunction(L, ts_lua_http_resp_cache_transformed);
-    lua_setfield(L, -2, "resp_cache_transformed");
+  lua_pushcfunction(L, ts_lua_http_resp_cache_transformed);
+  lua_setfield(L, -2, "resp_cache_transformed");
 
-    lua_pushcfunction(L, ts_lua_http_resp_cache_untransformed);
-    lua_setfield(L, -2, "resp_cache_untransformed");
+  lua_pushcfunction(L, ts_lua_http_resp_cache_untransformed);
+  lua_setfield(L, -2, "resp_cache_untransformed");
 }
 
 static void
-ts_lua_inject_cache_lookup_result_variables(lua_State *L)
+ts_lua_inject_cache_lookup_result_variables(lua_State * L)
 {
-    unsigned int     i;
+  unsigned int i;
 
-    for (i = 0; i < sizeof(ts_lua_cache_lookup_result_string)/sizeof(char*); i++) {
-        lua_pushinteger(L, i);
-        lua_setglobal(L, ts_lua_cache_lookup_result_string[i]);
-    }
+  for (i = 0; i < sizeof(ts_lua_cache_lookup_result_string) / sizeof(char *); i++) {
+    lua_pushinteger(L, i);
+    lua_setglobal(L, ts_lua_cache_lookup_result_string[i]);
+  }
 }
 
 static int
-ts_lua_http_set_retstatus(lua_State *L)
+ts_lua_http_set_retstatus(lua_State * L)
 {
-    int                 status;
-    ts_lua_http_ctx     *http_ctx;
+  int status;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    status = luaL_checkinteger(L, 1);
-    TSHttpTxnSetHttpRetStatus(http_ctx->txnp, status);
-    return 0;
+  status = luaL_checkinteger(L, 1);
+  TSHttpTxnSetHttpRetStatus(http_ctx->txnp, status);
+  return 0;
 }
 
 static int
-ts_lua_http_set_retbody(lua_State *L)
+ts_lua_http_set_retbody(lua_State * L)
 {
-    const char          *body;
-    size_t              body_len;
-    ts_lua_http_ctx     *http_ctx;
+  const char *body;
+  size_t body_len;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    body = luaL_checklstring(L, 1, &body_len);
-    TSHttpTxnErrorBodySet(http_ctx->txnp, TSstrdup(body), body_len, NULL); // Defaults to text/html
-    return 0;
+  body = luaL_checklstring(L, 1, &body_len);
+  TSHttpTxnErrorBodySet(http_ctx->txnp, TSstrdup(body), body_len, NULL);        // Defaults to text/html
+  return 0;
 }
 
 static int
-ts_lua_http_set_resp(lua_State *L)
+ts_lua_http_set_resp(lua_State * L)
 {
-    int                 n, status;
-    const char          *body;
-    size_t              body_len;
-    ts_lua_http_ctx     *http_ctx;
+  int n, status;
+  const char *body;
+  size_t body_len;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    n = lua_gettop(L);
+  n = lua_gettop(L);
 
-    status = luaL_checkinteger(L, 1);
-    TSHttpTxnSetHttpRetStatus(http_ctx->txnp, status);
+  status = luaL_checkinteger(L, 1);
+  TSHttpTxnSetHttpRetStatus(http_ctx->txnp, status);
 
-    if (n == 2) {
-        body = luaL_checklstring(L, 2, &body_len);
-        TSHttpTxnErrorBodySet(http_ctx->txnp, TSstrdup(body), body_len, NULL); // Defaults to text/html
-    }
+  if (n == 2) {
+    body = luaL_checklstring(L, 2, &body_len);
+    TSHttpTxnErrorBodySet(http_ctx->txnp, TSstrdup(body), body_len, NULL);      // Defaults to text/html
+  }
 
-    return 0;
+  return 0;
 }
 
 static int
-ts_lua_http_get_cache_lookup_status(lua_State *L)
+ts_lua_http_get_cache_lookup_status(lua_State * L)
 {
-    int                 status;
+  int status;
 
-    ts_lua_http_ctx     *http_ctx;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    if (TSHttpTxnCacheLookupStatusGet(http_ctx->txnp, &status) == TS_ERROR) {
-        lua_pushnil(L);
-    } else {
-        lua_pushnumber(L, status);
-    }
+  if (TSHttpTxnCacheLookupStatusGet(http_ctx->txnp, &status) == TS_ERROR) {
+    lua_pushnil(L);
+  } else {
+    lua_pushnumber(L, status);
+  }
 
-    return 1;
+  return 1;
 }
 
 static int
-ts_lua_http_set_cache_url(lua_State *L)
+ts_lua_http_set_cache_url(lua_State * L)
 {
-    const char          *url;
-    size_t              url_len;
+  const char *url;
+  size_t url_len;
 
-    ts_lua_http_ctx     *http_ctx;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    url = luaL_checklstring(L, 1, &url_len);
+  url = luaL_checklstring(L, 1, &url_len);
 
-    if (url && url_len) {
-        TSCacheUrlSet(http_ctx->txnp, url, url_len);
-    }
+  if (url && url_len) {
+    TSCacheUrlSet(http_ctx->txnp, url, url_len);
+  }
 
-    return 0;
+  return 0;
 }
 
 static int
-ts_lua_http_resp_cache_transformed(lua_State *L)
+ts_lua_http_resp_cache_transformed(lua_State * L)
 {
-    int                 action;
-    ts_lua_http_ctx     *http_ctx;
+  int action;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    action = luaL_checkinteger(L, 1);
+  action = luaL_checkinteger(L, 1);
 
-    TSHttpTxnTransformedRespCache(http_ctx->txnp, action);
+  TSHttpTxnTransformedRespCache(http_ctx->txnp, action);
 
-    return 0;
+  return 0;
 }
 
 static int
-ts_lua_http_resp_cache_untransformed(lua_State *L)
+ts_lua_http_resp_cache_untransformed(lua_State * L)
 {
-    int                 action;
-    ts_lua_http_ctx     *http_ctx;
+  int action;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    action = luaL_checkinteger(L, 1);
+  action = luaL_checkinteger(L, 1);
 
-    TSHttpTxnUntransformedRespCache(http_ctx->txnp, action);
+  TSHttpTxnUntransformedRespCache(http_ctx->txnp, action);
 
-    return 0;
+  return 0;
 }
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_http.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_http.h b/plugins/experimental/ts_lua/ts_lua_http.h
index 7de74a9..0b70a4a 100644
--- a/plugins/experimental/ts_lua/ts_lua_http.h
+++ b/plugins/experimental/ts_lua/ts_lua_http.h
@@ -22,7 +22,6 @@
 
 #include "ts_lua_common.h"
 
-void ts_lua_inject_http_api(lua_State *L);
+void ts_lua_inject_http_api(lua_State * L);
 
 #endif
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_http_intercept.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_http_intercept.c b/plugins/experimental/ts_lua/ts_lua_http_intercept.c
index bb4b1c8..88d41cd 100644
--- a/plugins/experimental/ts_lua/ts_lua_http_intercept.c
+++ b/plugins/experimental/ts_lua/ts_lua_http_intercept.c
@@ -22,278 +22,278 @@
 #define TS_LUA_FUNCTION_HTTP_INTERCEPT            "do_intercept"
 #define TS_LUA_FUNCTION_HTTP_SERVER_INTERCEPT     "do_server_intercept"
 
-typedef enum {
-    TS_LUA_TYPE_HTTP_INTERCEPT = 0,
-    TS_LUA_TYPE_HTTP_SERVER_INTERCEPT = 1
+typedef enum
+{
+  TS_LUA_TYPE_HTTP_INTERCEPT = 0,
+  TS_LUA_TYPE_HTTP_SERVER_INTERCEPT = 1
 } TSInterceptType;
 
-static int ts_lua_http_intercept(lua_State *L);
-static int ts_lua_http_server_intercept(lua_State *L);
+static int ts_lua_http_intercept(lua_State * L);
+static int ts_lua_http_server_intercept(lua_State * L);
 static int ts_lua_http_intercept_entry(TSCont contp, TSEvent event, void *edata);
-static void ts_lua_http_intercept_process(ts_lua_http_ctx *http_ctx, TSVConn conn);
-static void ts_lua_http_intercept_setup_read(ts_lua_http_intercept_ctx *ictx);
-static void ts_lua_http_intercept_setup_write(ts_lua_http_intercept_ctx *ictx);
+static void ts_lua_http_intercept_process(ts_lua_http_ctx * http_ctx, TSVConn conn);
+static void ts_lua_http_intercept_setup_read(ts_lua_http_intercept_ctx * ictx);
+static void ts_lua_http_intercept_setup_write(ts_lua_http_intercept_ctx * ictx);
 static int ts_lua_http_intercept_handler(TSCont contp, TSEvent event, void *edata);
-static int ts_lua_http_intercept_run_coroutine(ts_lua_http_intercept_ctx *ictx);
-static int ts_lua_http_intercept_process_read(TSEvent event, ts_lua_http_intercept_ctx *ictx);
-static int ts_lua_http_intercept_process_write(TSEvent event, ts_lua_http_intercept_ctx *ictx);
+static int ts_lua_http_intercept_run_coroutine(ts_lua_http_intercept_ctx * ictx);
+static int ts_lua_http_intercept_process_read(TSEvent event, ts_lua_http_intercept_ctx * ictx);
+static int ts_lua_http_intercept_process_write(TSEvent event, ts_lua_http_intercept_ctx * ictx);
 
 
 void
-ts_lua_inject_http_intercept_api(lua_State *L)
+ts_lua_inject_http_intercept_api(lua_State * L)
 {
-    lua_pushcfunction(L, ts_lua_http_intercept);
-    lua_setfield(L, -2, "intercept");
+  lua_pushcfunction(L, ts_lua_http_intercept);
+  lua_setfield(L, -2, "intercept");
 
-    lua_pushcfunction(L, ts_lua_http_server_intercept);
-    lua_setfield(L, -2, "server_intercept");
+  lua_pushcfunction(L, ts_lua_http_server_intercept);
+  lua_setfield(L, -2, "server_intercept");
 }
 
 static int
-ts_lua_http_intercept(lua_State *L)
+ts_lua_http_intercept(lua_State * L)
 {
-    TSCont              contp;
-    int                 type;
-    ts_lua_http_ctx     *http_ctx;
+  TSCont contp;
+  int type;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    type = lua_type(L, 1);
+  type = lua_type(L, 1);
 
-    if (type != LUA_TFUNCTION) {
-        fprintf(stderr, "[%s] param in ts.http.intercept should be a function\n", __FUNCTION__);
-        return 0;
-    }
+  if (type != LUA_TFUNCTION) {
+    fprintf(stderr, "[%s] param in ts.http.intercept should be a function\n", __FUNCTION__);
+    return 0;
+  }
 
-    lua_pushvalue(L, 1);
-    lua_setglobal(L, TS_LUA_FUNCTION_HTTP_INTERCEPT);
+  lua_pushvalue(L, 1);
+  lua_setglobal(L, TS_LUA_FUNCTION_HTTP_INTERCEPT);
 
-    http_ctx->intercept_type = TS_LUA_TYPE_HTTP_INTERCEPT;
+  http_ctx->intercept_type = TS_LUA_TYPE_HTTP_INTERCEPT;
 
-    contp = TSContCreate(ts_lua_http_intercept_entry, TSMutexCreate());
-    TSContDataSet(contp, http_ctx);
-    TSHttpTxnIntercept(contp, http_ctx->txnp);
+  contp = TSContCreate(ts_lua_http_intercept_entry, TSMutexCreate());
+  TSContDataSet(contp, http_ctx);
+  TSHttpTxnIntercept(contp, http_ctx->txnp);
 
-    return 0;
+  return 0;
 }
 
 static int
-ts_lua_http_server_intercept(lua_State *L)
+ts_lua_http_server_intercept(lua_State * L)
 {
-    TSCont              contp;
-    int                 type;
-    ts_lua_http_ctx     *http_ctx;
+  TSCont contp;
+  int type;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    type = lua_type(L, 1);
+  type = lua_type(L, 1);
 
-    if (type != LUA_TFUNCTION) {
-        fprintf(stderr, "[%s] param in ts.http.server_intercept should be a function\n", __FUNCTION__);
-        return 0;
-    }
+  if (type != LUA_TFUNCTION) {
+    fprintf(stderr, "[%s] param in ts.http.server_intercept should be a function\n", __FUNCTION__);
+    return 0;
+  }
 
-    lua_pushvalue(L, 1);
-    lua_setglobal(L, TS_LUA_FUNCTION_HTTP_SERVER_INTERCEPT);
+  lua_pushvalue(L, 1);
+  lua_setglobal(L, TS_LUA_FUNCTION_HTTP_SERVER_INTERCEPT);
 
-    http_ctx->intercept_type = TS_LUA_TYPE_HTTP_SERVER_INTERCEPT;
+  http_ctx->intercept_type = TS_LUA_TYPE_HTTP_SERVER_INTERCEPT;
 
-    contp = TSContCreate(ts_lua_http_intercept_entry, TSMutexCreate());
-    TSContDataSet(contp, http_ctx);
-    TSHttpTxnServerIntercept(contp, http_ctx->txnp);
+  contp = TSContCreate(ts_lua_http_intercept_entry, TSMutexCreate());
+  TSContDataSet(contp, http_ctx);
+  TSHttpTxnServerIntercept(contp, http_ctx->txnp);
 
-    return 0;
+  return 0;
 }
 
 
 static int
 ts_lua_http_intercept_entry(TSCont contp, TSEvent event, void *edata)
 {
-    switch (event) {
+  switch (event) {
 
-        case TS_EVENT_NET_ACCEPT_FAILED:
-            if (edata)
-                TSVConnClose((TSVConn)edata);
-            break;
+  case TS_EVENT_NET_ACCEPT_FAILED:
+    if (edata)
+      TSVConnClose((TSVConn) edata);
+    break;
 
-        case TS_EVENT_NET_ACCEPT:
-            ts_lua_http_intercept_process((ts_lua_http_ctx*)TSContDataGet(contp), (TSVConn)edata);
-            break;
+  case TS_EVENT_NET_ACCEPT:
+    ts_lua_http_intercept_process((ts_lua_http_ctx *) TSContDataGet(contp), (TSVConn) edata);
+    break;
 
-        default:
-            break;
-    }
+  default:
+    break;
+  }
 
-    TSContDestroy(contp);
-    return 0;
+  TSContDestroy(contp);
+  return 0;
 }
 
 static void
-ts_lua_http_intercept_process(ts_lua_http_ctx *http_ctx, TSVConn conn)
+ts_lua_http_intercept_process(ts_lua_http_ctx * http_ctx, TSVConn conn)
 {
-    TSCont          contp;
-    lua_State       *l;
-    TSMutex         mtxp;
-    ts_lua_http_intercept_ctx   *ictx;
+  TSCont contp;
+  lua_State *l;
+  TSMutex mtxp;
+  ts_lua_http_intercept_ctx *ictx;
 
-    mtxp = http_ctx->mctx->mutexp;
-    TSMutexLock(mtxp);
+  mtxp = http_ctx->mctx->mutexp;
+  TSMutexLock(mtxp);
 
-    ictx = ts_lua_create_http_intercept_ctx(http_ctx);
+  ictx = ts_lua_create_http_intercept_ctx(http_ctx);
 
-    contp = TSContCreate(ts_lua_http_intercept_handler, TSMutexCreate());
-    TSContDataSet(contp, ictx);
+  contp = TSContCreate(ts_lua_http_intercept_handler, TSMutexCreate());
+  TSContDataSet(contp, ictx);
 
-    ictx->contp = contp;
-    ictx->net_vc = conn;
+  ictx->contp = contp;
+  ictx->net_vc = conn;
 
-    l = ictx->lua;
+  l = ictx->lua;
 
-    // set up read.
-    ts_lua_http_intercept_setup_read(ictx);
+  // set up read.
+  ts_lua_http_intercept_setup_read(ictx);
 
-    // invoke function here
-    if (http_ctx->intercept_type == TS_LUA_TYPE_HTTP_INTERCEPT) {
-        lua_getglobal(l, TS_LUA_FUNCTION_HTTP_INTERCEPT);
-    } else {
-        lua_getglobal(l, TS_LUA_FUNCTION_HTTP_SERVER_INTERCEPT);
-    }
+  // invoke function here
+  if (http_ctx->intercept_type == TS_LUA_TYPE_HTTP_INTERCEPT) {
+    lua_getglobal(l, TS_LUA_FUNCTION_HTTP_INTERCEPT);
+  } else {
+    lua_getglobal(l, TS_LUA_FUNCTION_HTTP_SERVER_INTERCEPT);
+  }
 
-    ts_lua_http_intercept_run_coroutine(ictx);
+  ts_lua_http_intercept_run_coroutine(ictx);
 
-    TSMutexUnlock(mtxp);
+  TSMutexUnlock(mtxp);
 
 }
 
 static void
-ts_lua_http_intercept_setup_read(ts_lua_http_intercept_ctx *ictx)
+ts_lua_http_intercept_setup_read(ts_lua_http_intercept_ctx * ictx)
 {
-    ictx->input.buffer = TSIOBufferCreate();
-    ictx->input.reader = TSIOBufferReaderAlloc(ictx->input.buffer);
-    ictx->input.vio = TSVConnRead(ictx->net_vc, ictx->contp, ictx->input.buffer, INT64_MAX);
+  ictx->input.buffer = TSIOBufferCreate();
+  ictx->input.reader = TSIOBufferReaderAlloc(ictx->input.buffer);
+  ictx->input.vio = TSVConnRead(ictx->net_vc, ictx->contp, ictx->input.buffer, INT64_MAX);
 }
 
 static void
-ts_lua_http_intercept_setup_write(ts_lua_http_intercept_ctx *ictx)
+ts_lua_http_intercept_setup_write(ts_lua_http_intercept_ctx * ictx)
 {
-    ictx->output.buffer = TSIOBufferCreate();
-    ictx->output.reader = TSIOBufferReaderAlloc(ictx->output.buffer);
-    ictx->output.vio = TSVConnWrite(ictx->net_vc, ictx->contp, ictx->output.reader, INT64_MAX);
+  ictx->output.buffer = TSIOBufferCreate();
+  ictx->output.reader = TSIOBufferReaderAlloc(ictx->output.buffer);
+  ictx->output.vio = TSVConnWrite(ictx->net_vc, ictx->contp, ictx->output.reader, INT64_MAX);
 }
 
 static int
 ts_lua_http_intercept_handler(TSCont contp, TSEvent event, void *edata)
 {
-    int             ret;
-    TSMutex         mtxp;
-    ts_lua_http_intercept_ctx *ictx;
-
-    ictx = (ts_lua_http_intercept_ctx*)TSContDataGet(contp);
-    mtxp = NULL;
+  int ret;
+  TSMutex mtxp;
+  ts_lua_http_intercept_ctx *ictx;
 
-    if (edata == ictx->input.vio) {
-        ret = ts_lua_http_intercept_process_read(event, ictx);
+  ictx = (ts_lua_http_intercept_ctx *) TSContDataGet(contp);
+  mtxp = NULL;
 
-    } else if (edata == ictx->output.vio) {
-        ret = ts_lua_http_intercept_process_write(event, ictx);
+  if (edata == ictx->input.vio) {
+    ret = ts_lua_http_intercept_process_read(event, ictx);
 
-    } else {
-        mtxp = ictx->hctx->mctx->mutexp;
-        TSMutexLock(mtxp);
-        ret = ts_lua_http_intercept_run_coroutine(ictx);
-    }
+  } else if (edata == ictx->output.vio) {
+    ret = ts_lua_http_intercept_process_write(event, ictx);
 
-    if (ret || (ictx->send_complete && ictx->recv_complete)) {
+  } else {
+    mtxp = ictx->hctx->mctx->mutexp;
+    TSMutexLock(mtxp);
+    ret = ts_lua_http_intercept_run_coroutine(ictx);
+  }
 
-        TSContDestroy(contp);
+  if (ret || (ictx->send_complete && ictx->recv_complete)) {
 
-        if (!mtxp) {
-            mtxp = ictx->hctx->mctx->mutexp;
-            TSMutexLock(mtxp);
-        }
+    TSContDestroy(contp);
 
-        ts_lua_destroy_http_intercept_ctx(ictx);
+    if (!mtxp) {
+      mtxp = ictx->hctx->mctx->mutexp;
+      TSMutexLock(mtxp);
     }
 
-    if (mtxp)
-        TSMutexUnlock(mtxp);
+    ts_lua_destroy_http_intercept_ctx(ictx);
+  }
 
-    return 0;
+  if (mtxp)
+    TSMutexUnlock(mtxp);
+
+  return 0;
 }
 
 static int
-ts_lua_http_intercept_run_coroutine(ts_lua_http_intercept_ctx *ictx)
+ts_lua_http_intercept_run_coroutine(ts_lua_http_intercept_ctx * ictx)
 {
-    int             ret;
-    const char      *res;
-    size_t          res_len;
-    lua_State       *L;
+  int ret;
+  const char *res;
+  size_t res_len;
+  lua_State *L;
 
-    L = ictx->lua;
+  L = ictx->lua;
 
-    ret = lua_resume(L, 0);
+  ret = lua_resume(L, 0);
 
-    switch (ret) {
+  switch (ret) {
 
-        case 0:             // finished
-            res = lua_tolstring(L, -1, &res_len);
-            ts_lua_http_intercept_setup_write(ictx);
-            TSIOBufferWrite(ictx->output.buffer, res, res_len);
-            TSVIONBytesSet(ictx->output.vio, res_len);
-            break;
+  case 0:                      // finished
+    res = lua_tolstring(L, -1, &res_len);
+    ts_lua_http_intercept_setup_write(ictx);
+    TSIOBufferWrite(ictx->output.buffer, res, res_len);
+    TSVIONBytesSet(ictx->output.vio, res_len);
+    break;
 
-        case 1:             // yield
-            break;
+  case 1:                      // yield
+    break;
 
-        default:            // error
-            fprintf(stderr, "lua_resume failed: %s\n", lua_tostring(L, -1));
-            return -1;
-    }
+  default:                     // error
+    fprintf(stderr, "lua_resume failed: %s\n", lua_tostring(L, -1));
+    return -1;
+  }
 
-    return 0;
+  return 0;
 }
 
 static int
-ts_lua_http_intercept_process_read(TSEvent event, ts_lua_http_intercept_ctx *ictx)
+ts_lua_http_intercept_process_read(TSEvent event, ts_lua_http_intercept_ctx * ictx)
 {
-    int64_t avail = TSIOBufferReaderAvail(ictx->input.reader);
-    TSIOBufferReaderConsume(ictx->input.reader, avail);
+  int64_t avail = TSIOBufferReaderAvail(ictx->input.reader);
+  TSIOBufferReaderConsume(ictx->input.reader, avail);
 
-    switch (event) {
+  switch (event) {
 
-        case TS_EVENT_VCONN_READ_READY:
-            TSVConnShutdown(ictx->net_vc, 1, 0);
+  case TS_EVENT_VCONN_READ_READY:
+    TSVConnShutdown(ictx->net_vc, 1, 0);
 
-        case TS_EVENT_VCONN_READ_COMPLETE:
-        case TS_EVENT_VCONN_EOS:
-            ictx->recv_complete = 1;
-            break;
+  case TS_EVENT_VCONN_READ_COMPLETE:
+  case TS_EVENT_VCONN_EOS:
+    ictx->recv_complete = 1;
+    break;
 
-        default:
-            return -1;
-    }
+  default:
+    return -1;
+  }
 
-    return 0;
+  return 0;
 }
 
 static int
-ts_lua_http_intercept_process_write(TSEvent event, ts_lua_http_intercept_ctx *ictx)
+ts_lua_http_intercept_process_write(TSEvent event, ts_lua_http_intercept_ctx * ictx)
 {
-    switch (event) {
-        case TS_EVENT_VCONN_WRITE_READY:
-            if (TSIOBufferReaderAvail(ictx->output.reader))
-                TSVIOReenable(ictx->output.vio);
-            break;
-
-        case TS_EVENT_VCONN_WRITE_COMPLETE:
-            ictx->send_complete = 1;
-            break;
-
-        case TS_EVENT_ERROR:
-        default:
-            return -1; 
-    }   
-
-    return 0;
+  switch (event) {
+  case TS_EVENT_VCONN_WRITE_READY:
+    if (TSIOBufferReaderAvail(ictx->output.reader))
+      TSVIOReenable(ictx->output.vio);
+    break;
+
+  case TS_EVENT_VCONN_WRITE_COMPLETE:
+    ictx->send_complete = 1;
+    break;
+
+  case TS_EVENT_ERROR:
+  default:
+    return -1;
+  }
+
+  return 0;
 }
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_http_intercept.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_http_intercept.h b/plugins/experimental/ts_lua/ts_lua_http_intercept.h
index 7bf344e..2403e11 100644
--- a/plugins/experimental/ts_lua/ts_lua_http_intercept.h
+++ b/plugins/experimental/ts_lua/ts_lua_http_intercept.h
@@ -22,7 +22,6 @@
 
 #include "ts_lua_common.h"
 
-void ts_lua_inject_http_intercept_api(lua_State *L);
+void ts_lua_inject_http_intercept_api(lua_State * L);
 
 #endif
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_log.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_log.c b/plugins/experimental/ts_lua/ts_lua_log.c
index cf58d6f..400589c 100644
--- a/plugins/experimental/ts_lua/ts_lua_log.c
+++ b/plugins/experimental/ts_lua/ts_lua_log.c
@@ -21,97 +21,96 @@
 
 static TSTextLogObject log;
 
-static int ts_lua_log_object_creat(lua_State *L);
-static int ts_lua_log_object_write(lua_State *L);
-static int ts_lua_log_object_destroy(lua_State *L);
+static int ts_lua_log_object_creat(lua_State * L);
+static int ts_lua_log_object_write(lua_State * L);
+static int ts_lua_log_object_destroy(lua_State * L);
 
 
-static void ts_lua_inject_log_object_creat_api(lua_State *L);
-static void ts_lua_inject_log_object_write_api(lua_State *L);
-static void ts_lua_inject_log_object_destroy_api(lua_State *L);
+static void ts_lua_inject_log_object_creat_api(lua_State * L);
+static void ts_lua_inject_log_object_write_api(lua_State * L);
+static void ts_lua_inject_log_object_destroy_api(lua_State * L);
 
 void
-ts_lua_inject_log_api(lua_State *L)
+ts_lua_inject_log_api(lua_State * L)
 {
-    lua_newtable(L);
+  lua_newtable(L);
 
-    ts_lua_inject_log_object_creat_api(L);
-    ts_lua_inject_log_object_write_api(L);
-    ts_lua_inject_log_object_destroy_api(L);
+  ts_lua_inject_log_object_creat_api(L);
+  ts_lua_inject_log_object_write_api(L);
+  ts_lua_inject_log_object_destroy_api(L);
 
-    lua_setfield(L, -2, "log");
+  lua_setfield(L, -2, "log");
 }
 
 static void
 ts_lua_inject_log_object_creat_api(lua_State * L)
 {
-    lua_pushcfunction(L, ts_lua_log_object_creat);
-    lua_setfield(L, -2, "object_creat");
+  lua_pushcfunction(L, ts_lua_log_object_creat);
+  lua_setfield(L, -2, "object_creat");
 }
 
-static int 
-ts_lua_log_object_creat(lua_State *L)
+static int
+ts_lua_log_object_creat(lua_State * L)
 {
-    const char *log_name;
-    size_t name_len;
-    int log_mode;
-    TSReturnCode error;
+  const char *log_name;
+  size_t name_len;
+  int log_mode;
+  TSReturnCode error;
 
-    log_name = luaL_checklstring(L, -2, &name_len);
+  log_name = luaL_checklstring(L, -2, &name_len);
 
-    if (lua_isnil(L, 3)) {
-        TSError("no log name!!");
-        return -1;
-    } else {
-        log_mode = luaL_checknumber(L, 3);
+  if (lua_isnil(L, 3)) {
+    TSError("no log name!!");
+    return -1;
+  } else {
+    log_mode = luaL_checknumber(L, 3);
 
-    }
+  }
 
-    error = TSTextLogObjectCreate(log_name, log_mode, &log);
+  error = TSTextLogObjectCreate(log_name, log_mode, &log);
 
-    if(!log || error == TS_ERROR)
-    {
-        TSError("creat log error <%s>",log_name);
-        return -1;
-    }
-    return 0;
+  if (!log || error == TS_ERROR) {
+    TSError("creat log error <%s>", log_name);
+    return -1;
+  }
+  return 0;
 }
 
-static void 
+static void
 ts_lua_inject_log_object_write_api(lua_State * L)
 {
-    lua_pushcfunction(L, ts_lua_log_object_write);
-    lua_setfield(L,-2,"object_write");
+  lua_pushcfunction(L, ts_lua_log_object_write);
+  lua_setfield(L, -2, "object_write");
 }
 
 static int
-ts_lua_log_object_write(lua_State *L)
+ts_lua_log_object_write(lua_State * L)
 {
-    const char  *text;
-    size_t      text_len;
+  const char *text;
+  size_t text_len;
 
-    text = luaL_checklstring(L, 1, &text_len);
-    if(log) {
-        TSTextLogObjectWrite(log, "%s", text);
-    } else {
-        TSError("[%s] log is not exsited!",__FUNCTION__);
-    }
+  text = luaL_checklstring(L, 1, &text_len);
+  if (log) {
+    TSTextLogObjectWrite(log, "%s", text);
+  } else {
+    TSError("[%s] log is not exsited!", __FUNCTION__);
+  }
 
-    return 0;
+  return 0;
 }
 
-static void 
+static void
 ts_lua_inject_log_object_destroy_api(lua_State * L)
 {
-    lua_pushcfunction(L, ts_lua_log_object_destroy);
-    lua_setfield(L,-2,"object_destroy");
+  lua_pushcfunction(L, ts_lua_log_object_destroy);
+  lua_setfield(L, -2, "object_destroy");
 }
 
 static int
-ts_lua_log_object_destroy(lua_State *L ATS_UNUSED )
+ts_lua_log_object_destroy(lua_State * L ATS_UNUSED)
 {
-    if(TSTextLogObjectDestroy(log) != TS_SUCCESS)
-        TSError("[%s] TSTextLogObjectDestroy error!",__FUNCTION__);
+  if (TSTextLogObjectDestroy(log) != TS_SUCCESS)
+    TSError("[%s] TSTextLogObjectDestroy error!", __FUNCTION__);
 
-    return 0;
+  return 0;
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_log.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_log.h b/plugins/experimental/ts_lua/ts_lua_log.h
index 886805e..4029c2d 100644
--- a/plugins/experimental/ts_lua/ts_lua_log.h
+++ b/plugins/experimental/ts_lua/ts_lua_log.h
@@ -22,6 +22,6 @@
 
 #include "ts_lua_common.h"
 
-void ts_lua_inject_log_api(lua_State *L);
+void ts_lua_inject_log_api(lua_State * L);
 
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_misc.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_misc.c b/plugins/experimental/ts_lua/ts_lua_misc.c
index 1d0b258..05a8155 100644
--- a/plugins/experimental/ts_lua/ts_lua_misc.c
+++ b/plugins/experimental/ts_lua/ts_lua_misc.c
@@ -20,72 +20,71 @@
 #include "ts_lua_util.h"
 
 
-static int ts_lua_get_now_time(lua_State *L);
-static int ts_lua_debug(lua_State *L);
-static int ts_lua_error(lua_State *L);
-static int ts_lua_sleep(lua_State *L);
+static int ts_lua_get_now_time(lua_State * L);
+static int ts_lua_debug(lua_State * L);
+static int ts_lua_error(lua_State * L);
+static int ts_lua_sleep(lua_State * L);
 
 
 void
-ts_lua_inject_misc_api(lua_State *L)
+ts_lua_inject_misc_api(lua_State * L)
 {
-    /* ts.now() */
-    lua_pushcfunction(L, ts_lua_get_now_time);
-    lua_setfield(L, -2, "now");
+  /* ts.now() */
+  lua_pushcfunction(L, ts_lua_get_now_time);
+  lua_setfield(L, -2, "now");
 
-    /* ts.debug(...) */
-    lua_pushcfunction(L, ts_lua_debug);
-    lua_setfield(L, -2, "debug");
+  /* ts.debug(...) */
+  lua_pushcfunction(L, ts_lua_debug);
+  lua_setfield(L, -2, "debug");
 
-    /* ts.error(...) */
-    lua_pushcfunction(L, ts_lua_error);
-    lua_setfield(L, -2, "error");
+  /* ts.error(...) */
+  lua_pushcfunction(L, ts_lua_error);
+  lua_setfield(L, -2, "error");
 
-    /* ts.sleep(...) */
-    lua_pushcfunction(L, ts_lua_sleep);
-    lua_setfield(L, -2, "sleep");
+  /* ts.sleep(...) */
+  lua_pushcfunction(L, ts_lua_sleep);
+  lua_setfield(L, -2, "sleep");
 }
 
 static int
-ts_lua_get_now_time(lua_State *L)
+ts_lua_get_now_time(lua_State * L)
 {
-    time_t    now;
+  time_t now;
 
-    now = TShrtime() / 1000000000;
-    lua_pushnumber(L, now);
-    return 1;
+  now = TShrtime() / 1000000000;
+  lua_pushnumber(L, now);
+  return 1;
 }
 
 static int
-ts_lua_debug(lua_State *L)
+ts_lua_debug(lua_State * L)
 {
-    const char      *msg;
+  const char *msg;
 
-    msg = luaL_checkstring(L, 1);
-    TSDebug(TS_LUA_DEBUG_TAG, "%s", msg);
-    return 0;
+  msg = luaL_checkstring(L, 1);
+  TSDebug(TS_LUA_DEBUG_TAG, "%s", msg);
+  return 0;
 }
 
 static int
-ts_lua_error(lua_State *L)
+ts_lua_error(lua_State * L)
 {
-    const char      *msg;
+  const char *msg;
 
-    msg = luaL_checkstring(L, 1);
-    TSError("%s", msg);
-    return 0;
+  msg = luaL_checkstring(L, 1);
+  TSError("%s", msg);
+  return 0;
 }
 
 static int
-ts_lua_sleep(lua_State *L)
+ts_lua_sleep(lua_State * L)
 {
-    int     sec;
-    ts_lua_http_intercept_ctx *ictx;
+  int sec;
+  ts_lua_http_intercept_ctx *ictx;
 
-    ictx = ts_lua_get_http_intercept_ctx(L);
-    sec = luaL_checknumber(L, 1);
+  ictx = ts_lua_get_http_intercept_ctx(L);
+  sec = luaL_checknumber(L, 1);
 
-    TSContSchedule(ictx->contp, sec*1000, TS_THREAD_POOL_DEFAULT);
-    return lua_yield(L, 0);
+  TSContSchedule(ictx->contp, sec * 1000, TS_THREAD_POOL_DEFAULT);
+  return lua_yield(L, 0);
 }
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_misc.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_misc.h b/plugins/experimental/ts_lua/ts_lua_misc.h
index 14c8b03..3ce86cc 100644
--- a/plugins/experimental/ts_lua/ts_lua_misc.h
+++ b/plugins/experimental/ts_lua/ts_lua_misc.h
@@ -22,7 +22,6 @@
 
 #include "ts_lua_common.h"
 
-void ts_lua_inject_misc_api(lua_State *L);
+void ts_lua_inject_misc_api(lua_State * L);
 
 #endif
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_remap.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_remap.c b/plugins/experimental/ts_lua/ts_lua_remap.c
index d6efaaf..1678d22 100644
--- a/plugins/experimental/ts_lua/ts_lua_remap.c
+++ b/plugins/experimental/ts_lua/ts_lua_remap.c
@@ -20,48 +20,48 @@
 #include "ts_lua_remap.h"
 
 
-typedef enum {
-    TS_LUA_REMAP_NO_REMAP = 0,
-    TS_LUA_REMAP_DID_REMAP,
-    TS_LUA_REMAP_NO_REMAP_STOP,
-    TS_LUA_REMAP_DID_REMAP_STOP,
-    TS_LUA_REMAP_ERROR = -1,
+typedef enum
+{
+  TS_LUA_REMAP_NO_REMAP = 0,
+  TS_LUA_REMAP_DID_REMAP,
+  TS_LUA_REMAP_NO_REMAP_STOP,
+  TS_LUA_REMAP_DID_REMAP_STOP,
+  TS_LUA_REMAP_ERROR = -1,
 } TSLuaRemapStatus;
 
 int ts_lua_remap_status_id[] = {
-    TS_LUA_REMAP_NO_REMAP,
-    TS_LUA_REMAP_DID_REMAP,
-    TS_LUA_REMAP_NO_REMAP_STOP,
-    TS_LUA_REMAP_DID_REMAP_STOP,
-    TS_LUA_REMAP_ERROR,
+  TS_LUA_REMAP_NO_REMAP,
+  TS_LUA_REMAP_DID_REMAP,
+  TS_LUA_REMAP_NO_REMAP_STOP,
+  TS_LUA_REMAP_DID_REMAP_STOP,
+  TS_LUA_REMAP_ERROR,
 };
 
-char * ts_lua_remap_status_string[] = {
-    "TS_LUA_REMAP_NO_REMAP",
-    "TS_LUA_REMAP_DID_REMAP",
-    "TS_LUA_REMAP_NO_REMAP_STOP",
-    "TS_LUA_REMAP_DID_REMAP_STOP",
-    "TS_LUA_REMAP_ERROR",
+char *ts_lua_remap_status_string[] = {
+  "TS_LUA_REMAP_NO_REMAP",
+  "TS_LUA_REMAP_DID_REMAP",
+  "TS_LUA_REMAP_NO_REMAP_STOP",
+  "TS_LUA_REMAP_DID_REMAP_STOP",
+  "TS_LUA_REMAP_ERROR",
 };
 
 
-static void ts_lua_inject_remap_variables(lua_State *L);
+static void ts_lua_inject_remap_variables(lua_State * L);
 
 
 void
-ts_lua_inject_remap_api(lua_State *L)
+ts_lua_inject_remap_api(lua_State * L)
 {
-    ts_lua_inject_remap_variables(L);
+  ts_lua_inject_remap_variables(L);
 }
 
 static void
-ts_lua_inject_remap_variables(lua_State *L)
+ts_lua_inject_remap_variables(lua_State * L)
 {
-    int     i;
+  int i;
 
-    for (i = 0; i < sizeof(ts_lua_remap_status_string)/sizeof(char*); i++) {
-        lua_pushinteger(L, ts_lua_remap_status_id[i]);
-        lua_setglobal(L, ts_lua_remap_status_string[i]);
-    }
+  for (i = 0; i < sizeof(ts_lua_remap_status_string) / sizeof(char *); i++) {
+    lua_pushinteger(L, ts_lua_remap_status_id[i]);
+    lua_setglobal(L, ts_lua_remap_status_string[i]);
+  }
 }
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_remap.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_remap.h b/plugins/experimental/ts_lua/ts_lua_remap.h
index 1dc84ed..ef24ac2 100644
--- a/plugins/experimental/ts_lua/ts_lua_remap.h
+++ b/plugins/experimental/ts_lua/ts_lua_remap.h
@@ -22,7 +22,6 @@
 
 #include "ts_lua_common.h"
 
-void ts_lua_inject_remap_api(lua_State *L);
+void ts_lua_inject_remap_api(lua_State * L);
 
 #endif
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_server_request.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_server_request.c b/plugins/experimental/ts_lua/ts_lua_server_request.c
index 07853e3..3a38a6c 100644
--- a/plugins/experimental/ts_lua/ts_lua_server_request.c
+++ b/plugins/experimental/ts_lua/ts_lua_server_request.c
@@ -20,188 +20,191 @@
 #include <arpa/inet.h>
 #include "ts_lua_util.h"
 
-static void ts_lua_inject_server_request_header_api(lua_State *L);
-static void ts_lua_inject_server_request_get_header_size_api(lua_State *L);
-static void ts_lua_inject_server_request_get_body_size_api(lua_State *L);
+static void ts_lua_inject_server_request_header_api(lua_State * L);
+static void ts_lua_inject_server_request_get_header_size_api(lua_State * L);
+static void ts_lua_inject_server_request_get_body_size_api(lua_State * L);
 
-static int ts_lua_server_request_header_get(lua_State *L);
-static int ts_lua_server_request_header_set(lua_State *L);
-static int ts_lua_server_request_get_header_size(lua_State *L);
-static int ts_lua_server_request_get_body_size(lua_State *L);
+static int ts_lua_server_request_header_get(lua_State * L);
+static int ts_lua_server_request_header_set(lua_State * L);
+static int ts_lua_server_request_get_header_size(lua_State * L);
+static int ts_lua_server_request_get_body_size(lua_State * L);
 
 
 void
-ts_lua_inject_server_request_api(lua_State *L)
+ts_lua_inject_server_request_api(lua_State * L)
 {
-    lua_newtable(L);
+  lua_newtable(L);
 
-    ts_lua_inject_server_request_header_api(L);
-    ts_lua_inject_server_request_get_header_size_api(L);
-    ts_lua_inject_server_request_get_body_size_api(L);
+  ts_lua_inject_server_request_header_api(L);
+  ts_lua_inject_server_request_get_header_size_api(L);
+  ts_lua_inject_server_request_get_body_size_api(L);
 
-    lua_setfield(L, -2, "server_request");
+  lua_setfield(L, -2, "server_request");
 }
 
 
 static void
-ts_lua_inject_server_request_header_api(lua_State *L)
+ts_lua_inject_server_request_header_api(lua_State * L)
 {
-    lua_newtable(L);         /* .header */
+  lua_newtable(L);              /* .header */
 
-    lua_createtable(L, 0, 2);       /* metatable for .header */
+  lua_createtable(L, 0, 2);     /* metatable for .header */
 
-    lua_pushcfunction(L, ts_lua_server_request_header_get);
-    lua_setfield(L, -2, "__index");
-    lua_pushcfunction(L, ts_lua_server_request_header_set);
-    lua_setfield(L, -2, "__newindex");
+  lua_pushcfunction(L, ts_lua_server_request_header_get);
+  lua_setfield(L, -2, "__index");
+  lua_pushcfunction(L, ts_lua_server_request_header_set);
+  lua_setfield(L, -2, "__newindex");
 
-    lua_setmetatable(L, -2);
+  lua_setmetatable(L, -2);
 
-    lua_setfield(L, -2, "header");
+  lua_setfield(L, -2, "header");
 }
 
 static int
-ts_lua_server_request_header_get(lua_State *L)
+ts_lua_server_request_header_get(lua_State * L)
 {
-    const char  *key;
-    const char  *val;
-    int         val_len;
-    size_t      key_len;
+  const char *key;
+  const char *val;
+  int val_len;
+  size_t key_len;
 
-    TSMLoc      field_loc;
-    ts_lua_http_ctx  *http_ctx;
+  TSMLoc field_loc;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    /*  we skip the first argument that is the table */
-    key = luaL_checklstring(L, 2, &key_len);
+  /*  we skip the first argument that is the table */
+  key = luaL_checklstring(L, 2, &key_len);
 
-    if (!http_ctx->server_request_hdrp) {
-        if (TSHttpTxnServerReqGet(http_ctx->txnp,
-                    &http_ctx->server_request_bufp, &http_ctx->server_request_hdrp) != TS_SUCCESS) {
+  if (!http_ctx->server_request_hdrp) {
+    if (TSHttpTxnServerReqGet(http_ctx->txnp,
+                              &http_ctx->server_request_bufp, &http_ctx->server_request_hdrp) != TS_SUCCESS) {
 
-            lua_pushnil(L);
-            return 1;
-        }
+      lua_pushnil(L);
+      return 1;
     }
+  }
 
-    if (key && key_len) {
+  if (key && key_len) {
 
-        field_loc = TSMimeHdrFieldFind(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, key, key_len);
-        if (field_loc) {
-            val = TSMimeHdrFieldValueStringGet(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc, -1, &val_len);
-            lua_pushlstring(L, val, val_len);
-            TSHandleMLocRelease(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc);
-
-        } else {
-            lua_pushnil(L);
-        }
+    field_loc = TSMimeHdrFieldFind(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, key, key_len);
+    if (field_loc) {
+      val =
+        TSMimeHdrFieldValueStringGet(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc, -1,
+                                     &val_len);
+      lua_pushlstring(L, val, val_len);
+      TSHandleMLocRelease(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc);
 
     } else {
-        lua_pushnil(L);
+      lua_pushnil(L);
     }
 
-    return 1;
+  } else {
+    lua_pushnil(L);
+  }
+
+  return 1;
 }
 
 static int
-ts_lua_server_request_header_set(lua_State *L)
+ts_lua_server_request_header_set(lua_State * L)
 {
-    const char  *key;
-    const char  *val;
-    size_t      val_len;
-    size_t      key_len;
-    int         remove;
+  const char *key;
+  const char *val;
+  size_t val_len;
+  size_t key_len;
+  int remove;
 
-    TSMLoc      field_loc;
+  TSMLoc field_loc;
 
-    ts_lua_http_ctx  *http_ctx;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    remove = 0;
-    val = NULL;
+  remove = 0;
+  val = NULL;
 
-    /*   we skip the first argument that is the table */
-    key = luaL_checklstring(L, 2, &key_len);
-    if (lua_isnil(L, 3)) {
-        remove = 1;
-    } else {
-        val = luaL_checklstring(L, 3, &val_len);
-    }
+  /*   we skip the first argument that is the table */
+  key = luaL_checklstring(L, 2, &key_len);
+  if (lua_isnil(L, 3)) {
+    remove = 1;
+  } else {
+    val = luaL_checklstring(L, 3, &val_len);
+  }
 
-    if (!http_ctx->server_request_hdrp) {
-        if (TSHttpTxnServerReqGet(http_ctx->txnp,
-                    &http_ctx->server_request_bufp, &http_ctx->server_request_hdrp) != TS_SUCCESS) {
-            return 0;
-        }
+  if (!http_ctx->server_request_hdrp) {
+    if (TSHttpTxnServerReqGet(http_ctx->txnp,
+                              &http_ctx->server_request_bufp, &http_ctx->server_request_hdrp) != TS_SUCCESS) {
+      return 0;
     }
+  }
 
-    field_loc = TSMimeHdrFieldFind(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, key, key_len);
+  field_loc = TSMimeHdrFieldFind(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, key, key_len);
 
-    if (remove) {
-        if (field_loc) {
-            TSMimeHdrFieldDestroy(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc);
-        }
+  if (remove) {
+    if (field_loc) {
+      TSMimeHdrFieldDestroy(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc);
+    }
 
-    } else if (field_loc) {
-        TSMimeHdrFieldValueStringSet(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc, 0, val, val_len);
+  } else if (field_loc) {
+    TSMimeHdrFieldValueStringSet(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc, 0, val,
+                                 val_len);
 
-    } else if (TSMimeHdrFieldCreateNamed(http_ctx->server_request_bufp, http_ctx->server_request_hdrp,
-                key, key_len, &field_loc) != TS_SUCCESS) {
-        TSError("[%s] TSMimeHdrFieldCreateNamed error", __FUNCTION__);
-        return 0;
+  } else if (TSMimeHdrFieldCreateNamed(http_ctx->server_request_bufp, http_ctx->server_request_hdrp,
+                                       key, key_len, &field_loc) != TS_SUCCESS) {
+    TSError("[%s] TSMimeHdrFieldCreateNamed error", __FUNCTION__);
+    return 0;
 
-    } else {
-        TSMimeHdrFieldValueStringSet(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc, -1, val, val_len);
-        TSMimeHdrFieldAppend(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc);
-    }
+  } else {
+    TSMimeHdrFieldValueStringSet(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc, -1, val,
+                                 val_len);
+    TSMimeHdrFieldAppend(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc);
+  }
 
-    if (field_loc)
-        TSHandleMLocRelease(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc);
+  if (field_loc)
+    TSHandleMLocRelease(http_ctx->server_request_bufp, http_ctx->server_request_hdrp, field_loc);
 
-    return 0;
+  return 0;
 }
 
 static void
-ts_lua_inject_server_request_get_header_size_api(lua_State *L)
+ts_lua_inject_server_request_get_header_size_api(lua_State * L)
 {
-    lua_pushcfunction(L, ts_lua_server_request_get_header_size);
-    lua_setfield(L, -2, "get_header_size");	
+  lua_pushcfunction(L, ts_lua_server_request_get_header_size);
+  lua_setfield(L, -2, "get_header_size");
 }
 
 static int
-ts_lua_server_request_get_header_size(lua_State *L)
+ts_lua_server_request_get_header_size(lua_State * L)
 {
-    int header_size;
-    ts_lua_http_ctx  *http_ctx;
+  int header_size;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    header_size = TSHttpTxnServerReqHdrBytesGet(http_ctx->txnp);
-    lua_pushnumber(L,header_size);
+  header_size = TSHttpTxnServerReqHdrBytesGet(http_ctx->txnp);
+  lua_pushnumber(L, header_size);
 
-    return 1;
+  return 1;
 }
 
 static void
-ts_lua_inject_server_request_get_body_size_api(lua_State *L)
+ts_lua_inject_server_request_get_body_size_api(lua_State * L)
 {
-    lua_pushcfunction(L, ts_lua_server_request_get_body_size);
-    lua_setfield(L, -2, "get_body_size");
+  lua_pushcfunction(L, ts_lua_server_request_get_body_size);
+  lua_setfield(L, -2, "get_body_size");
 }
 
 static int
-ts_lua_server_request_get_body_size(lua_State *L)
+ts_lua_server_request_get_body_size(lua_State * L)
 {
-    int64_t body_size;
-    ts_lua_http_ctx  *http_ctx;
+  int64_t body_size;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    body_size = TSHttpTxnServerReqBodyBytesGet(http_ctx->txnp);
-    lua_pushnumber(L,body_size);
+  body_size = TSHttpTxnServerReqBodyBytesGet(http_ctx->txnp);
+  lua_pushnumber(L, body_size);
 
-    return 1;
+  return 1;
 }
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_server_request.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_server_request.h b/plugins/experimental/ts_lua/ts_lua_server_request.h
index c9996d6..40d5d09 100644
--- a/plugins/experimental/ts_lua/ts_lua_server_request.h
+++ b/plugins/experimental/ts_lua/ts_lua_server_request.h
@@ -22,7 +22,6 @@
 
 #include "ts_lua_common.h"
 
-void ts_lua_inject_server_request_api(lua_State *L);
+void ts_lua_inject_server_request_api(lua_State * L);
 
 #endif
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_server_response.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_server_response.c b/plugins/experimental/ts_lua/ts_lua_server_response.c
index 598e70a..ff6b41a 100644
--- a/plugins/experimental/ts_lua/ts_lua_server_response.c
+++ b/plugins/experimental/ts_lua/ts_lua_server_response.c
@@ -19,176 +19,179 @@
 
 #include "ts_lua_util.h"
 
-static void ts_lua_inject_server_response_header_api(lua_State *L);
-static void ts_lua_inject_server_response_header_misc_api(lua_State *L);
+static void ts_lua_inject_server_response_header_api(lua_State * L);
+static void ts_lua_inject_server_response_header_misc_api(lua_State * L);
 
-static int ts_lua_server_response_header_get(lua_State *L);
-static int ts_lua_server_response_header_set(lua_State *L);
+static int ts_lua_server_response_header_get(lua_State * L);
+static int ts_lua_server_response_header_set(lua_State * L);
 
-static int ts_lua_server_response_header_get_status(lua_State *L);
+static int ts_lua_server_response_header_get_status(lua_State * L);
 
 
 void
-ts_lua_inject_server_response_api(lua_State *L)
+ts_lua_inject_server_response_api(lua_State * L)
 {
-    lua_newtable(L);
+  lua_newtable(L);
 
-    ts_lua_inject_server_response_header_api(L);
+  ts_lua_inject_server_response_header_api(L);
 
-    lua_setfield(L, -2, "server_response");
+  lua_setfield(L, -2, "server_response");
 }
 
 
 static void
-ts_lua_inject_server_response_header_api(lua_State *L)
+ts_lua_inject_server_response_header_api(lua_State * L)
 {
-    lua_newtable(L);         /* .header */
+  lua_newtable(L);              /* .header */
 
-    ts_lua_inject_server_response_header_misc_api(L);
+  ts_lua_inject_server_response_header_misc_api(L);
 
-    lua_createtable(L, 0, 2);       /* metatable for .header */
+  lua_createtable(L, 0, 2);     /* metatable for .header */
 
-    lua_pushcfunction(L, ts_lua_server_response_header_get);
-    lua_setfield(L, -2, "__index");
-    lua_pushcfunction(L, ts_lua_server_response_header_set);
-    lua_setfield(L, -2, "__newindex");
+  lua_pushcfunction(L, ts_lua_server_response_header_get);
+  lua_setfield(L, -2, "__index");
+  lua_pushcfunction(L, ts_lua_server_response_header_set);
+  lua_setfield(L, -2, "__newindex");
 
-    lua_setmetatable(L, -2);
+  lua_setmetatable(L, -2);
 
-    lua_setfield(L, -2, "header");
+  lua_setfield(L, -2, "header");
 }
 
 static void
-ts_lua_inject_server_response_header_misc_api(lua_State *L)
+ts_lua_inject_server_response_header_misc_api(lua_State * L)
 {
-    lua_pushcfunction(L, ts_lua_server_response_header_get_status);
-    lua_setfield(L, -2, "get_status");
+  lua_pushcfunction(L, ts_lua_server_response_header_get_status);
+  lua_setfield(L, -2, "get_status");
 }
 
 static int
-ts_lua_server_response_header_get(lua_State *L)
+ts_lua_server_response_header_get(lua_State * L)
 {
-    const char  *key;
-    const char  *val;
-    int         val_len;
-    size_t      key_len;
+  const char *key;
+  const char *val;
+  int val_len;
+  size_t key_len;
 
-    TSMLoc      field_loc;
-    ts_lua_http_ctx  *http_ctx;
+  TSMLoc field_loc;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    /*  we skip the first argument that is the table */
-    key = luaL_checklstring(L, 2, &key_len);
+  /*  we skip the first argument that is the table */
+  key = luaL_checklstring(L, 2, &key_len);
 
-    if (!http_ctx->server_response_hdrp) {
-        if (TSHttpTxnServerRespGet(http_ctx->txnp,
-                    &http_ctx->server_response_bufp, &http_ctx->server_response_hdrp) != TS_SUCCESS) {
+  if (!http_ctx->server_response_hdrp) {
+    if (TSHttpTxnServerRespGet(http_ctx->txnp,
+                               &http_ctx->server_response_bufp, &http_ctx->server_response_hdrp) != TS_SUCCESS) {
 
-            lua_pushnil(L);
-            return 1;
-        }
+      lua_pushnil(L);
+      return 1;
     }
+  }
 
-    if (key && key_len) {
+  if (key && key_len) {
 
-        field_loc = TSMimeHdrFieldFind(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, key, key_len);
-        if (field_loc) {
-            val = TSMimeHdrFieldValueStringGet(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc, -1, &val_len);
-            lua_pushlstring(L, val, val_len);
-            TSHandleMLocRelease(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc);
-
-        } else {
-            lua_pushnil(L);
-        }
+    field_loc = TSMimeHdrFieldFind(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, key, key_len);
+    if (field_loc) {
+      val =
+        TSMimeHdrFieldValueStringGet(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc, -1,
+                                     &val_len);
+      lua_pushlstring(L, val, val_len);
+      TSHandleMLocRelease(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc);
 
     } else {
-        lua_pushnil(L);
+      lua_pushnil(L);
     }
 
-    return 1;
+  } else {
+    lua_pushnil(L);
+  }
+
+  return 1;
 }
 
 static int
-ts_lua_server_response_header_set(lua_State *L)
+ts_lua_server_response_header_set(lua_State * L)
 {
-    const char  *key;
-    const char  *val;
-    size_t      val_len;
-    size_t      key_len;
-    int         remove;
+  const char *key;
+  const char *val;
+  size_t val_len;
+  size_t key_len;
+  int remove;
 
-    TSMLoc      field_loc;
+  TSMLoc field_loc;
 
-    ts_lua_http_ctx  *http_ctx;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    remove = 0;
-    val = NULL;
+  remove = 0;
+  val = NULL;
 
-    /*   we skip the first argument that is the table */
-    key = luaL_checklstring(L, 2, &key_len);
-    if (lua_isnil(L, 3)) {
-        remove = 1;
-    } else {
-        val = luaL_checklstring(L, 3, &val_len);
-    }
+  /*   we skip the first argument that is the table */
+  key = luaL_checklstring(L, 2, &key_len);
+  if (lua_isnil(L, 3)) {
+    remove = 1;
+  } else {
+    val = luaL_checklstring(L, 3, &val_len);
+  }
 
-    if (!http_ctx->server_response_hdrp) {
-        if (TSHttpTxnServerRespGet(http_ctx->txnp,
-                    &http_ctx->server_response_bufp, &http_ctx->server_response_hdrp) != TS_SUCCESS) {
-            return 0;
-        }
+  if (!http_ctx->server_response_hdrp) {
+    if (TSHttpTxnServerRespGet(http_ctx->txnp,
+                               &http_ctx->server_response_bufp, &http_ctx->server_response_hdrp) != TS_SUCCESS) {
+      return 0;
     }
+  }
 
-    field_loc = TSMimeHdrFieldFind(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, key, key_len);
+  field_loc = TSMimeHdrFieldFind(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, key, key_len);
 
-    if (remove) {
-        if (field_loc) {
-            TSMimeHdrFieldDestroy(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc);
-        }
+  if (remove) {
+    if (field_loc) {
+      TSMimeHdrFieldDestroy(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc);
+    }
 
-    } else if (field_loc) {
-        TSMimeHdrFieldValueStringSet(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc, 0, val, val_len);
+  } else if (field_loc) {
+    TSMimeHdrFieldValueStringSet(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc, 0, val,
+                                 val_len);
 
-    } else if (TSMimeHdrFieldCreateNamed(http_ctx->server_response_bufp, http_ctx->server_response_hdrp,
-                key, key_len, &field_loc) != TS_SUCCESS) {
-        TSError("[%s] TSMimeHdrFieldCreateNamed error", __FUNCTION__);
-        return 0;
+  } else if (TSMimeHdrFieldCreateNamed(http_ctx->server_response_bufp, http_ctx->server_response_hdrp,
+                                       key, key_len, &field_loc) != TS_SUCCESS) {
+    TSError("[%s] TSMimeHdrFieldCreateNamed error", __FUNCTION__);
+    return 0;
 
-    } else {
-        TSMimeHdrFieldValueStringSet(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc, -1, val, val_len);
-        TSMimeHdrFieldAppend(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc);
-    }
+  } else {
+    TSMimeHdrFieldValueStringSet(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc, -1, val,
+                                 val_len);
+    TSMimeHdrFieldAppend(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc);
+  }
 
-    if (field_loc)
-        TSHandleMLocRelease(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc);
+  if (field_loc)
+    TSHandleMLocRelease(http_ctx->server_response_bufp, http_ctx->server_response_hdrp, field_loc);
 
-    return 0;
+  return 0;
 }
 
 static int
-ts_lua_server_response_header_get_status(lua_State *L)
+ts_lua_server_response_header_get_status(lua_State * L)
 {
-    int              status;
-    ts_lua_http_ctx  *http_ctx;
+  int status;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx = ts_lua_get_http_ctx(L);
 
-    if (!http_ctx->server_response_hdrp) {
-        if (TSHttpTxnServerRespGet(http_ctx->txnp,
-                    &http_ctx->server_response_bufp, &http_ctx->server_response_hdrp) != TS_SUCCESS) {
+  if (!http_ctx->server_response_hdrp) {
+    if (TSHttpTxnServerRespGet(http_ctx->txnp,
+                               &http_ctx->server_response_bufp, &http_ctx->server_response_hdrp) != TS_SUCCESS) {
 
-            lua_pushnil(L);
-            return 1;
-        }
+      lua_pushnil(L);
+      return 1;
     }
+  }
 
-    status = TSHttpHdrStatusGet(http_ctx->server_response_bufp, http_ctx->server_response_hdrp);
+  status = TSHttpHdrStatusGet(http_ctx->server_response_bufp, http_ctx->server_response_hdrp);
 
-    lua_pushinteger(L, status);
+  lua_pushinteger(L, status);
 
-    return 1;
+  return 1;
 }
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_server_response.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_server_response.h b/plugins/experimental/ts_lua/ts_lua_server_response.h
index fab0d17..9e89069 100644
--- a/plugins/experimental/ts_lua/ts_lua_server_response.h
+++ b/plugins/experimental/ts_lua/ts_lua_server_response.h
@@ -22,7 +22,6 @@
 
 #include "ts_lua_common.h"
 
-void ts_lua_inject_server_response_api(lua_State *L);
+void ts_lua_inject_server_response_api(lua_State * L);
 
 #endif
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_transform.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_transform.c b/plugins/experimental/ts_lua/ts_lua_transform.c
index 8bdb055..f196ea6 100644
--- a/plugins/experimental/ts_lua/ts_lua_transform.c
+++ b/plugins/experimental/ts_lua/ts_lua_transform.c
@@ -20,154 +20,153 @@
 #include "ts_lua_util.h"
 
 
-static int ts_lua_transform_handler(TSCont contp, ts_lua_transform_ctx *transform_ctx);
+static int ts_lua_transform_handler(TSCont contp, ts_lua_transform_ctx * transform_ctx);
 
 
 int
-ts_lua_transform_entry(TSCont contp, TSEvent event, void *edata ATS_UNUSED )
+ts_lua_transform_entry(TSCont contp, TSEvent event, void *edata ATS_UNUSED)
 {
-    TSVIO       input_vio;
+  TSVIO input_vio;
 
-    ts_lua_transform_ctx *transform_ctx = (ts_lua_transform_ctx*)TSContDataGet(contp);
+  ts_lua_transform_ctx *transform_ctx = (ts_lua_transform_ctx *) TSContDataGet(contp);
 
-    if (TSVConnClosedGet(contp)) {
-        TSContDestroy(contp);
-        ts_lua_destroy_transform_ctx(transform_ctx);
-        return 0;
-    }
+  if (TSVConnClosedGet(contp)) {
+    TSContDestroy(contp);
+    ts_lua_destroy_transform_ctx(transform_ctx);
+    return 0;
+  }
 
-    switch (event) {
+  switch (event) {
 
-        case TS_EVENT_ERROR:
-            input_vio = TSVConnWriteVIOGet(contp);
-            TSContCall(TSVIOContGet(input_vio), TS_EVENT_ERROR, input_vio);
-            break;
+  case TS_EVENT_ERROR:
+    input_vio = TSVConnWriteVIOGet(contp);
+    TSContCall(TSVIOContGet(input_vio), TS_EVENT_ERROR, input_vio);
+    break;
 
-        case TS_EVENT_VCONN_WRITE_COMPLETE:
-            TSVConnShutdown(TSTransformOutputVConnGet(contp), 0, 1);
-            break;
+  case TS_EVENT_VCONN_WRITE_COMPLETE:
+    TSVConnShutdown(TSTransformOutputVConnGet(contp), 0, 1);
+    break;
 
-        case TS_EVENT_VCONN_WRITE_READY:
-        default:
-            ts_lua_transform_handler(contp, transform_ctx);
-            break;
-    }
+  case TS_EVENT_VCONN_WRITE_READY:
+  default:
+    ts_lua_transform_handler(contp, transform_ctx);
+    break;
+  }
 
-    return 0;
+  return 0;
 }
 
 static int
-ts_lua_transform_handler(TSCont contp, ts_lua_transform_ctx *transform_ctx)
+ts_lua_transform_handler(TSCont contp, ts_lua_transform_ctx * transform_ctx)
 {
-    TSVConn             output_conn;
-    TSVIO               input_vio;
-    TSIOBufferReader    input_reader;
-    TSIOBufferBlock     blk;
-    int64_t             towrite, blk_len, upstream_done, avail, left;
-    const char          *start;
-    const char          *res;
-    size_t              res_len;
-    int                 ret, eos;
-
-    lua_State           *L;
-    TSMutex             mtxp;
-
-    L = transform_ctx->hctx->lua;
-    mtxp = transform_ctx->hctx->mctx->mutexp;
-
-    output_conn = TSTransformOutputVConnGet(contp);
-    input_vio = TSVConnWriteVIOGet(contp);
-    input_reader = TSVIOReaderGet(input_vio);
-
-    if (!transform_ctx->output_buffer) {
-        transform_ctx->output_buffer = TSIOBufferCreate();
-        transform_ctx->output_reader = TSIOBufferReaderAlloc(transform_ctx->output_buffer);
-        transform_ctx->output_vio = TSVConnWrite(output_conn, contp, transform_ctx->output_reader, INT64_MAX);
-    }
-
-    if (!TSVIOBufferGet(input_vio)) {
-        TSVIONBytesSet(transform_ctx->output_vio, transform_ctx->total);
-        TSVIOReenable(transform_ctx->output_vio);
-        return 1;
-    }
+  TSVConn output_conn;
+  TSVIO input_vio;
+  TSIOBufferReader input_reader;
+  TSIOBufferBlock blk;
+  int64_t towrite, blk_len, upstream_done, avail, left;
+  const char *start;
+  const char *res;
+  size_t res_len;
+  int ret, eos;
+
+  lua_State *L;
+  TSMutex mtxp;
+
+  L = transform_ctx->hctx->lua;
+  mtxp = transform_ctx->hctx->mctx->mutexp;
+
+  output_conn = TSTransformOutputVConnGet(contp);
+  input_vio = TSVConnWriteVIOGet(contp);
+  input_reader = TSVIOReaderGet(input_vio);
+
+  if (!transform_ctx->output_buffer) {
+    transform_ctx->output_buffer = TSIOBufferCreate();
+    transform_ctx->output_reader = TSIOBufferReaderAlloc(transform_ctx->output_buffer);
+    transform_ctx->output_vio = TSVConnWrite(output_conn, contp, transform_ctx->output_reader, INT64_MAX);
+  }
+
+  if (!TSVIOBufferGet(input_vio)) {
+    TSVIONBytesSet(transform_ctx->output_vio, transform_ctx->total);
+    TSVIOReenable(transform_ctx->output_vio);
+    return 1;
+  }
 
-    if (transform_ctx->eos) {
-        return 1;
-    }
+  if (transform_ctx->eos) {
+    return 1;
+  }
 
-    left = towrite = TSVIONTodoGet(input_vio);
-    upstream_done = TSVIONDoneGet(input_vio);
-    avail = TSIOBufferReaderAvail(input_reader);
-    eos = 0;
+  left = towrite = TSVIONTodoGet(input_vio);
+  upstream_done = TSVIONDoneGet(input_vio);
+  avail = TSIOBufferReaderAvail(input_reader);
+  eos = 0;
 
-    if (left <= avail)
-        eos = 1;
+  if (left <= avail)
+    eos = 1;
 
-    if (towrite > avail)
-        towrite = avail;
+  if (towrite > avail)
+    towrite = avail;
 
-    TSMutexLock(mtxp);
+  TSMutexLock(mtxp);
 
-    blk = TSIOBufferReaderStart(input_reader);
+  blk = TSIOBufferReaderStart(input_reader);
 
-    do {
-        start = TSIOBufferBlockReadStart(blk, input_reader, &blk_len);
+  do {
+    start = TSIOBufferBlockReadStart(blk, input_reader, &blk_len);
 
-        lua_pushlightuserdata(L, transform_ctx);
-        lua_rawget(L, LUA_GLOBALSINDEX);                /* push function */
+    lua_pushlightuserdata(L, transform_ctx);
+    lua_rawget(L, LUA_GLOBALSINDEX);    /* push function */
 
-        if (towrite > blk_len) {
-            lua_pushlstring(L, start, (size_t)blk_len);
-            towrite -= blk_len;
-        } else {
-            lua_pushlstring(L, start, (size_t)towrite);
-            towrite = 0;
-        }
+    if (towrite > blk_len) {
+      lua_pushlstring(L, start, (size_t) blk_len);
+      towrite -= blk_len;
+    } else {
+      lua_pushlstring(L, start, (size_t) towrite);
+      towrite = 0;
+    }
 
-        if (!towrite && eos) {
-            lua_pushinteger(L, 1);                          /* second param, not finish */ 
-        } else {
-            lua_pushinteger(L, 0);                          /* second param, not finish */ 
-        }
+    if (!towrite && eos) {
+      lua_pushinteger(L, 1);    /* second param, not finish */
+    } else {
+      lua_pushinteger(L, 0);    /* second param, not finish */
+    }
 
-        if (lua_pcall(L, 2, 2, 0)) {
-            fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(L, -1));
-        }
+    if (lua_pcall(L, 2, 2, 0)) {
+      fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(L, -1));
+    }
 
-        ret = lua_tointeger(L, -1);                         /* 0 is not finished, 1 is finished */
-        res = lua_tolstring(L, -2, &res_len);
+    ret = lua_tointeger(L, -1); /* 0 is not finished, 1 is finished */
+    res = lua_tolstring(L, -2, &res_len);
 
-        if (res && res_len) {
-            TSIOBufferWrite(transform_ctx->output_buffer, res, res_len);
-            transform_ctx->total += res_len;
-        }
+    if (res && res_len) {
+      TSIOBufferWrite(transform_ctx->output_buffer, res, res_len);
+      transform_ctx->total += res_len;
+    }
 
-        lua_pop(L, 2);
+    lua_pop(L, 2);
 
-        if (ret || (eos && !towrite)) {            // EOS
-            eos = 1;
-            break;
-        }
+    if (ret || (eos && !towrite)) {     // EOS
+      eos = 1;
+      break;
+    }
 
-        blk = TSIOBufferBlockNext(blk);
+    blk = TSIOBufferBlockNext(blk);
 
-    } while (blk && towrite > 0);
+  } while (blk && towrite > 0);
 
-    TSMutexUnlock(mtxp);
+  TSMutexUnlock(mtxp);
 
-    TSIOBufferReaderConsume(input_reader, avail);
-    TSVIONDoneSet(input_vio, upstream_done + avail);
+  TSIOBufferReaderConsume(input_reader, avail);
+  TSVIONDoneSet(input_vio, upstream_done + avail);
 
-    if (eos) {
-        transform_ctx->eos = 1;
-        TSVIONBytesSet(transform_ctx->output_vio, transform_ctx->total);
-        TSVIOReenable(transform_ctx->output_vio);
-        TSContCall(TSVIOContGet(input_vio), TS_EVENT_VCONN_WRITE_COMPLETE, input_vio);
-    } else {
-        TSVIOReenable(transform_ctx->output_vio);
-        TSContCall(TSVIOContGet(input_vio), TS_EVENT_VCONN_WRITE_READY, input_vio);
-    }
+  if (eos) {
+    transform_ctx->eos = 1;
+    TSVIONBytesSet(transform_ctx->output_vio, transform_ctx->total);
+    TSVIOReenable(transform_ctx->output_vio);
+    TSContCall(TSVIOContGet(input_vio), TS_EVENT_VCONN_WRITE_COMPLETE, input_vio);
+  } else {
+    TSVIOReenable(transform_ctx->output_vio);
+    TSContCall(TSVIOContGet(input_vio), TS_EVENT_VCONN_WRITE_READY, input_vio);
+  }
 
-    return 1;
+  return 1;
 }
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_transform.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_transform.h b/plugins/experimental/ts_lua/ts_lua_transform.h
index c8b6568..b05294e 100644
--- a/plugins/experimental/ts_lua/ts_lua_transform.h
+++ b/plugins/experimental/ts_lua/ts_lua_transform.h
@@ -25,4 +25,3 @@
 int ts_lua_transform_entry(TSCont contp, TSEvent event, void *edata);
 
 #endif
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/63007927/plugins/experimental/ts_lua/ts_lua_util.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_util.c b/plugins/experimental/ts_lua/ts_lua_util.c
index 81231ee..72e742d 100644
--- a/plugins/experimental/ts_lua/ts_lua_util.c
+++ b/plugins/experimental/ts_lua/ts_lua_util.c
@@ -30,434 +30,433 @@
 #include "ts_lua_misc.h"
 #include "ts_lua_log.h"
 
-static lua_State * ts_lua_new_state();
-static void ts_lua_init_registry(lua_State *L);
-static void ts_lua_init_globals(lua_State *L);
-static void ts_lua_inject_ts_api(lua_State *L);
+static lua_State *ts_lua_new_state();
+static void ts_lua_init_registry(lua_State * L);
+static void ts_lua_init_globals(lua_State * L);
+static void ts_lua_inject_ts_api(lua_State * L);
 
 
 int
-ts_lua_create_vm(ts_lua_main_ctx *arr, int n)
+ts_lua_create_vm(ts_lua_main_ctx * arr, int n)
 {
-    int         i;
-    lua_State   *L;
+  int i;
+  lua_State *L;
 
-    for (i = 0; i < n; i++) {
+  for (i = 0; i < n; i++) {
 
-        L = ts_lua_new_state();
+    L = ts_lua_new_state();
 
-        if (L == NULL)
-            return -1;
+    if (L == NULL)
+      return -1;
 
-        lua_pushvalue(L, LUA_GLOBALSINDEX);
+    lua_pushvalue(L, LUA_GLOBALSINDEX);
 
-        arr[i].gref = luaL_ref(L, LUA_REGISTRYINDEX);
-        arr[i].lua = L;
-        arr[i].mutexp = TSMutexCreate();
-    }
+    arr[i].gref = luaL_ref(L, LUA_REGISTRYINDEX);
+    arr[i].lua = L;
+    arr[i].mutexp = TSMutexCreate();
+  }
 
-    return 0;
+  return 0;
 }
 
 void
-ts_lua_destroy_vm(ts_lua_main_ctx *arr, int n)
+ts_lua_destroy_vm(ts_lua_main_ctx * arr, int n)
 {
-    int         i;
-    lua_State   *L;
+  int i;
+  lua_State *L;
 
-    for (i = 0; i < n; i++) {
+  for (i = 0; i < n; i++) {
 
-        L = arr[i].lua;
-        if (L)
-            lua_close(L);
-    }
+    L = arr[i].lua;
+    if (L)
+      lua_close(L);
+  }
 
-    return;
+  return;
 }
 
 lua_State *
 ts_lua_new_state()
 {
-    lua_State   *L;
+  lua_State *L;
 
-    L = luaL_newstate();
+  L = luaL_newstate();
 
-    if (L == NULL) {
-        return NULL;
-    }
+  if (L == NULL) {
+    return NULL;
+  }
 
-    luaL_openlibs(L);
+  luaL_openlibs(L);
 
-    ts_lua_init_registry(L);
+  ts_lua_init_registry(L);
 
-    ts_lua_init_globals(L);
+  ts_lua_init_globals(L);
 
-    return L;
+  return L;
 }
 
 int
-ts_lua_add_module(ts_lua_instance_conf *conf, ts_lua_main_ctx *arr, int n, int argc, char *argv[])
+ts_lua_add_module(ts_lua_instance_conf * conf, ts_lua_main_ctx * arr, int n, int argc, char *argv[])
 {
-    int             i, ret;
-    int             t;
-    lua_State       *L;
-
-    for (i = 0; i < n; i++) {
+  int i, ret;
+  int t;
+  lua_State *L;
 
-        L = arr[i].lua;
+  for (i = 0; i < n; i++) {
 
-        lua_newtable(L);                                    // create this module's global table
-        lua_pushvalue(L, -1);
-        lua_setfield(L, -2, "_G");
-        lua_newtable(L);
-        lua_rawgeti(L, LUA_REGISTRYINDEX, arr[i].gref);
-        lua_setfield(L, -2, "__index");
-        lua_setmetatable(L, -2);
-        lua_replace(L, LUA_GLOBALSINDEX);
+    L = arr[i].lua;
 
-        if (luaL_loadfile(L, conf->script)) {
-            fprintf(stderr, "[%s] luaL_loadfile %s failed: %s\n", __FUNCTION__, conf->script, lua_tostring(L, -1));
-            lua_pop(L, 1);
-            return -1;
-        }
+    lua_newtable(L);            // create this module's global table
+    lua_pushvalue(L, -1);
+    lua_setfield(L, -2, "_G");
+    lua_newtable(L);
+    lua_rawgeti(L, LUA_REGISTRYINDEX, arr[i].gref);
+    lua_setfield(L, -2, "__index");
+    lua_setmetatable(L, -2);
+    lua_replace(L, LUA_GLOBALSINDEX);
+
+    if (luaL_loadfile(L, conf->script)) {
+      fprintf(stderr, "[%s] luaL_loadfile %s failed: %s\n", __FUNCTION__, conf->script, lua_tostring(L, -1));
+      lua_pop(L, 1);
+      return -1;
+    }
 
-        if (lua_pcall(L, 0, 0, 0)) {
-            fprintf(stderr, "[%s] lua_pcall %s failed: %s\n", __FUNCTION__, conf->script, lua_tostring(L, -1));
-            lua_pop(L, 1);
-            return -1;
-        }
+    if (lua_pcall(L, 0, 0, 0)) {
+      fprintf(stderr, "[%s] lua_pcall %s failed: %s\n", __FUNCTION__, conf->script, lua_tostring(L, -1));
+      lua_pop(L, 1);
+      return -1;
+    }
 
-        /* call "__init__", to parse parameters */
-        lua_getglobal(L, "__init__");
+    /* call "__init__", to parse parameters */
+    lua_getglobal(L, "__init__");
 
-        if (lua_type(L, -1) == LUA_TFUNCTION) {
+    if (lua_type(L, -1) == LUA_TFUNCTION) {
 
-            lua_newtable(L);
+      lua_newtable(L);
 
-            for (t = 0; t < argc; t++) {
-                lua_pushnumber(L, t);
-                lua_pushstring(L, argv[t]);
-                lua_rawset(L, -3);
-            }
+      for (t = 0; t < argc; t++) {
+        lua_pushnumber(L, t);
+        lua_pushstring(L, argv[t]);
+        lua_rawset(L, -3);
+      }
 
-            if (lua_pcall(L, 1, 1, 0)) {
-                fprintf(stderr, "[%s] lua_pcall %s failed: %s\n", __FUNCTION__, conf->script, lua_tostring(L, -1));
-                lua_pop(L, 1);
-                return -1;
-            }
+      if (lua_pcall(L, 1, 1, 0)) {
+        fprintf(stderr, "[%s] lua_pcall %s failed: %s\n", __FUNCTION__, conf->script, lua_tostring(L, -1));
+        lua_pop(L, 1);
+        return -1;
+      }
 
-            ret = lua_tonumber(L, -1);
-            lua_pop(L, 1);
+      ret = lua_tonumber(L, -1);
+      lua_pop(L, 1);
 
-            if (ret)
-                return -1;          /* script parse error */
+      if (ret)
+        return -1;              /* script parse error */
 
-        } else {
-            lua_pop(L, 1);          /* pop nil */
-        }
+    } else {
+      lua_pop(L, 1);            /* pop nil */
+    }
 
 
-        lua_pushlightuserdata(L, conf);
-        lua_pushvalue(L, LUA_GLOBALSINDEX);
-        lua_rawset(L, LUA_REGISTRYINDEX);
+    lua_pushlightuserdata(L, conf);
+    lua_pushvalue(L, LUA_GLOBALSINDEX);
+    lua_rawset(L, LUA_REGISTRYINDEX);
 
-        lua_newtable(L);
-        lua_replace(L, LUA_GLOBALSINDEX);               // set empty table to global
-    }
+    lua_newtable(L);
+    lua_replace(L, LUA_GLOBALSINDEX);   // set empty table to global
+  }
 
 
-    return 0;
+  return 0;
 }
 
 
-static
-void ts_lua_init_registry(lua_State *L ATS_UNUSED)
+static void
+ts_lua_init_registry(lua_State * L ATS_UNUSED)
 {
-    return;
+  return;
 }
 
-static
-void ts_lua_init_globals(lua_State *L)
+static void
+ts_lua_init_globals(lua_State * L)
 {
-    ts_lua_inject_ts_api(L);
+  ts_lua_inject_ts_api(L);
 }
 
 static void
-ts_lua_inject_ts_api(lua_State *L)
+ts_lua_inject_ts_api(lua_State * L)
 {
-    lua_newtable(L);
+  lua_newtable(L);
 
-    ts_lua_inject_remap_api(L);
+  ts_lua_inject_remap_api(L);
 
-    ts_lua_inject_client_request_api(L);
-    ts_lua_inject_server_request_api(L);
-    ts_lua_inject_server_response_api(L);
-    ts_lua_inject_client_response_api(L);
-    ts_lua_inject_cached_response_api(L);
-    ts_lua_inject_log_api(L);
+  ts_lua_inject_client_request_api(L);
+  ts_lua_inject_server_request_api(L);
+  ts_lua_inject_server_response_api(L);
+  ts_lua_inject_client_response_api(L);
+  ts_lua_inject_cached_response_api(L);
+  ts_lua_inject_log_api(L);
 
-    ts_lua_inject_context_api(L);
-    ts_lua_inject_hook_api(L);
+  ts_lua_inject_context_api(L);
+  ts_lua_inject_hook_api(L);
 
-    ts_lua_inject_http_api(L);
-    ts_lua_inject_misc_api(L);
+  ts_lua_inject_http_api(L);
+  ts_lua_inject_misc_api(L);
 
-    lua_getglobal(L, "package");
-    lua_getfield(L, -1, "loaded");
-    lua_pushvalue(L, -3);
-    lua_setfield(L, -2, "ts");
-    lua_pop(L, 2);
+  lua_getglobal(L, "package");
+  lua_getfield(L, -1, "loaded");
+  lua_pushvalue(L, -3);
+  lua_setfield(L, -2, "ts");
+  lua_pop(L, 2);
 
-    lua_setglobal(L, "ts");
+  lua_setglobal(L, "ts");
 }
 
 void
-ts_lua_set_http_ctx(lua_State *L, ts_lua_http_ctx  *ctx)
+ts_lua_set_http_ctx(lua_State * L, ts_lua_http_ctx * ctx)
 {
-    lua_pushliteral(L, "__ts_http_ctx");
-    lua_pushlightuserdata(L, ctx);
-    lua_rawset(L, LUA_GLOBALSINDEX);
+  lua_pushliteral(L, "__ts_http_ctx");
+  lua_pushlightuserdata(L, ctx);
+  lua_rawset(L, LUA_GLOBALSINDEX);
 }
 
 ts_lua_http_ctx *
-ts_lua_get_http_ctx(lua_State *L)
+ts_lua_get_http_ctx(lua_State * L)
 {
-    ts_lua_http_ctx  *ctx;
+  ts_lua_http_ctx *ctx;
 
-    lua_pushliteral(L, "__ts_http_ctx");
-    lua_rawget(L, LUA_GLOBALSINDEX);
-    ctx = lua_touserdata(L, -1);
+  lua_pushliteral(L, "__ts_http_ctx");
+  lua_rawget(L, LUA_GLOBALSINDEX);
+  ctx = lua_touserdata(L, -1);
 
-    lua_pop(L, 1);                      // pop the ctx out
+  lua_pop(L, 1);                // pop the ctx out
 
-    return ctx;
+  return ctx;
 }
 
 ts_lua_http_ctx *
-ts_lua_create_http_ctx(ts_lua_main_ctx *main_ctx, ts_lua_instance_conf *conf)
+ts_lua_create_http_ctx(ts_lua_main_ctx * main_ctx, ts_lua_instance_conf * conf)
 {
-    ts_lua_http_ctx     *http_ctx;
-    lua_State           *L;
-    lua_State           *l;
+  ts_lua_http_ctx *http_ctx;
+  lua_State *L;
+  lua_State *l;
 
-    L = main_ctx->lua;
+  L = main_ctx->lua;
 
-    http_ctx = TSmalloc(sizeof(ts_lua_http_ctx));
-    memset(http_ctx, 0, sizeof(ts_lua_http_ctx));
+  http_ctx = TSmalloc(sizeof(ts_lua_http_ctx));
+  memset(http_ctx, 0, sizeof(ts_lua_http_ctx));
 
-    http_ctx->lua = lua_newthread(L);
-    l = http_ctx->lua;
+  http_ctx->lua = lua_newthread(L);
+  l = http_ctx->lua;
 
-    lua_pushlightuserdata(L, conf);
-    lua_rawget(L, LUA_REGISTRYINDEX);
+  lua_pushlightuserdata(L, conf);
+  lua_rawget(L, LUA_REGISTRYINDEX);
 
-    /* new globals table for coroutine */
-    lua_newtable(l);
-    lua_pushvalue(l, -1);
-    lua_setfield(l, -2, "_G"); 
-    lua_newtable(l);
-    lua_xmove(L, l, 1);
-    lua_setfield(l, -2, "__index");
-    lua_setmetatable(l, -2);
+  /* new globals table for coroutine */
+  lua_newtable(l);
+  lua_pushvalue(l, -1);
+  lua_setfield(l, -2, "_G");
+  lua_newtable(l);
+  lua_xmove(L, l, 1);
+  lua_setfield(l, -2, "__index");
+  lua_setmetatable(l, -2);
 
-    lua_replace(l, LUA_GLOBALSINDEX);
+  lua_replace(l, LUA_GLOBALSINDEX);
 
-    http_ctx->ref = luaL_ref(L, LUA_REGISTRYINDEX);
+  http_ctx->ref = luaL_ref(L, LUA_REGISTRYINDEX);
 
-    http_ctx->mctx = main_ctx;
+  http_ctx->mctx = main_ctx;
 
-    ts_lua_set_http_ctx(http_ctx->lua, http_ctx);
-    ts_lua_create_context_table(http_ctx->lua);
+  ts_lua_set_http_ctx(http_ctx->lua, http_ctx);
+  ts_lua_create_context_table(http_ctx->lua);
 
-    return http_ctx;
+  return http_ctx;
 }
 
 
 void
-ts_lua_destroy_http_ctx(ts_lua_http_ctx* http_ctx)
+ts_lua_destroy_http_ctx(ts_lua_http_ctx * http_ctx)
 {
-    ts_lua_main_ctx   *main_ctx;
+  ts_lua_main_ctx *main_ctx;
 
-    main_ctx = http_ctx->mctx;
+  main_ctx = http_ctx->mctx;
 
-    if(!http_ctx->remap) {
-      if(http_ctx->client_request_bufp) {
-        if(http_ctx->client_request_url) {
-          TSHandleMLocRelease(http_ctx->client_request_bufp, http_ctx->client_request_hdrp, http_ctx->client_request_url);
-        } 
-        TSHandleMLocRelease(http_ctx->client_request_bufp, TS_NULL_MLOC, http_ctx->client_request_hdrp);
+  if (!http_ctx->remap) {
+    if (http_ctx->client_request_bufp) {
+      if (http_ctx->client_request_url) {
+        TSHandleMLocRelease(http_ctx->client_request_bufp, http_ctx->client_request_hdrp, http_ctx->client_request_url);
       }
-    } 
-
-    if (http_ctx->server_request_bufp) {
-        TSHandleMLocRelease(http_ctx->server_request_bufp, TS_NULL_MLOC, http_ctx->server_request_hdrp);
+      TSHandleMLocRelease(http_ctx->client_request_bufp, TS_NULL_MLOC, http_ctx->client_request_hdrp);
     }
+  }
 
-    if (http_ctx->server_response_bufp) {
-        TSHandleMLocRelease(http_ctx->server_response_bufp, TS_NULL_MLOC, http_ctx->server_response_hdrp);
-    }
+  if (http_ctx->server_request_bufp) {
+    TSHandleMLocRelease(http_ctx->server_request_bufp, TS_NULL_MLOC, http_ctx->server_request_hdrp);
+  }
 
-    if (http_ctx->client_response_bufp) {
-        TSHandleMLocRelease(http_ctx->client_response_bufp, TS_NULL_MLOC, http_ctx->client_response_hdrp);
-    }
+  if (http_ctx->server_response_bufp) {
+    TSHandleMLocRelease(http_ctx->server_response_bufp, TS_NULL_MLOC, http_ctx->server_response_hdrp);
+  }
 
-    if (http_ctx->cached_response_bufp) {
-        TSHandleMLocRelease(http_ctx->cached_response_bufp, TS_NULL_MLOC, http_ctx->cached_response_hdrp);
-    }
+  if (http_ctx->client_response_bufp) {
+    TSHandleMLocRelease(http_ctx->client_response_bufp, TS_NULL_MLOC, http_ctx->client_response_hdrp);
+  }
+
+  if (http_ctx->cached_response_bufp) {
+    TSHandleMLocRelease(http_ctx->cached_response_bufp, TS_NULL_MLOC, http_ctx->cached_response_hdrp);
+  }
 
-    luaL_unref(main_ctx->lua, LUA_REGISTRYINDEX, http_ctx->ref);
-    TSfree(http_ctx);
+  luaL_unref(main_ctx->lua, LUA_REGISTRYINDEX, http_ctx->ref);
+  TSfree(http_ctx);
 }
 
 void
-ts_lua_set_http_intercept_ctx(lua_State *L, ts_lua_http_intercept_ctx  *ictx)
+ts_lua_set_http_intercept_ctx(lua_State * L, ts_lua_http_intercept_ctx * ictx)
 {
-    lua_pushliteral(L, "__ts_http_intercept_ctx");
-    lua_pushlightuserdata(L, ictx);
-    lua_rawset(L, LUA_GLOBALSINDEX);
+  lua_pushliteral(L, "__ts_http_intercept_ctx");
+  lua_pushlightuserdata(L, ictx);
+  lua_rawset(L, LUA_GLOBALSINDEX);
 }
 
 ts_lua_http_intercept_ctx *
-ts_lua_get_http_intercept_ctx(lua_State *L)
+ts_lua_get_http_intercept_ctx(lua_State * L)
 {
-    ts_lua_http_intercept_ctx  *ictx;
+  ts_lua_http_intercept_ctx *ictx;
 
-    lua_pushliteral(L, "__ts_http_intercept_ctx");
-    lua_rawget(L, LUA_GLOBALSINDEX);
-    ictx = lua_touserdata(L, -1);
+  lua_pushliteral(L, "__ts_http_intercept_ctx");
+  lua_rawget(L, LUA_GLOBALSINDEX);
+  ictx = lua_touserdata(L, -1);
 
-    lua_pop(L, 1);                      // pop the ictx out
+  lua_pop(L, 1);                // pop the ictx out
 
-    return ictx;
+  return ictx;
 }
 
 ts_lua_http_intercept_ctx *
-ts_lua_create_http_intercept_ctx(ts_lua_http_ctx *http_ctx)
+ts_lua_create_http_intercept_ctx(ts_lua_http_ctx * http_ctx)
 {
-    lua_State           *L;
-    ts_lua_http_intercept_ctx   *ictx;
+  lua_State *L;
+  ts_lua_http_intercept_ctx *ictx;
 
-    L = http_ctx->lua;
+  L = http_ctx->lua;
 
-    ictx = TSmalloc(sizeof(ts_lua_http_intercept_ctx));
-    memset(ictx, 0, sizeof(ts_lua_http_intercept_ctx));
+  ictx = TSmalloc(sizeof(ts_lua_http_intercept_ctx));
+  memset(ictx, 0, sizeof(ts_lua_http_intercept_ctx));
 
-    ictx->lua = lua_newthread(L);
+  ictx->lua = lua_newthread(L);
 
-    ictx->ref = luaL_ref(L, LUA_REGISTRYINDEX);
+  ictx->ref = luaL_ref(L, LUA_REGISTRYINDEX);
 
-    ictx->hctx = http_ctx;
+  ictx->hctx = http_ctx;
 
-    ts_lua_set_http_intercept_ctx(ictx->lua, ictx);
+  ts_lua_set_http_intercept_ctx(ictx->lua, ictx);
 
-    return ictx;
+  return ictx;
 }
 
-void 
-ts_lua_destroy_http_intercept_ctx(ts_lua_http_intercept_ctx *ictx)
+void
+ts_lua_destroy_http_intercept_ctx(ts_lua_http_intercept_ctx * ictx)
 {
-    ts_lua_http_ctx   *http_ctx;
+  ts_lua_http_ctx *http_ctx;
 
-    http_ctx = ictx->hctx;
+  http_ctx = ictx->hctx;
 
-    if (ictx->net_vc)
-        TSVConnClose(ictx->net_vc);
+  if (ictx->net_vc)
+    TSVConnClose(ictx->net_vc);
 
-    TS_LUA_RELEASE_IO_HANDLE((&ictx->input));
-    TS_LUA_RELEASE_IO_HANDLE((&ictx->output));
+  TS_LUA_RELEASE_IO_HANDLE((&ictx->input));
+  TS_LUA_RELEASE_IO_HANDLE((&ictx->output));
 
-    luaL_unref(http_ctx->lua, LUA_REGISTRYINDEX, ictx->ref);
-    TSfree(ictx);
-    return;
+  luaL_unref(http_ctx->lua, LUA_REGISTRYINDEX, ictx->ref);
+  TSfree(ictx);
+  return;
 }
 
-void 
-ts_lua_destroy_transform_ctx(ts_lua_transform_ctx *transform_ctx)
+void
+ts_lua_destroy_transform_ctx(ts_lua_transform_ctx * transform_ctx)
 {
-    if (!transform_ctx)
-        return;
+  if (!transform_ctx)
+    return;
 
-    if (transform_ctx->output_reader)
-        TSIOBufferReaderFree(transform_ctx->output_reader);
+  if (transform_ctx->output_reader)
+    TSIOBufferReaderFree(transform_ctx->output_reader);
 
-    if (transform_ctx->output_buffer)
-        TSIOBufferDestroy(transform_ctx->output_buffer);
+  if (transform_ctx->output_buffer)
+    TSIOBufferDestroy(transform_ctx->output_buffer);
 
-    TSfree(transform_ctx);
+  TSfree(transform_ctx);
 }
 
 int
 ts_lua_http_cont_handler(TSCont contp, TSEvent event, void *edata)
 {
-    TSHttpTxn           txnp = (TSHttpTxn)edata;
-    lua_State           *l;
-    ts_lua_http_ctx     *http_ctx;
-    ts_lua_main_ctx     *main_ctx;
+  TSHttpTxn txnp = (TSHttpTxn) edata;
+  lua_State *l;
+  ts_lua_http_ctx *http_ctx;
+  ts_lua_main_ctx *main_ctx;
 
-    http_ctx = (ts_lua_http_ctx*)TSContDataGet(contp);
-    main_ctx = http_ctx->mctx;
+  http_ctx = (ts_lua_http_ctx *) TSContDataGet(contp);
+  main_ctx = http_ctx->mctx;
 
-    l = http_ctx->lua;
+  l = http_ctx->lua;
 
-    TSMutexLock(main_ctx->mutexp);
+  TSMutexLock(main_ctx->mutexp);
 
-    switch (event) {
+  switch (event) {
 
-        case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE:
+  case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE:
 
-            lua_getglobal(l, TS_LUA_FUNCTION_CACHE_LOOKUP_COMPLETE);
-            if (lua_type(l, -1) == LUA_TFUNCTION) {
-                if (lua_pcall(l, 0, 1, 0)) {
-                    fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
-                }
-            }
+    lua_getglobal(l, TS_LUA_FUNCTION_CACHE_LOOKUP_COMPLETE);
+    if (lua_type(l, -1) == LUA_TFUNCTION) {
+      if (lua_pcall(l, 0, 1, 0)) {
+        fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
+      }
+    }
 
-            break;
+    break;
 
-        case TS_EVENT_HTTP_SEND_REQUEST_HDR:
+  case TS_EVENT_HTTP_SEND_REQUEST_HDR:
 
-            lua_getglobal(l, TS_LUA_FUNCTION_SEND_REQUEST);
-            if (lua_type(l, -1) == LUA_TFUNCTION) {
-                if (lua_pcall(l, 0, 1, 0)) {
-                    fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
-                }
-            }
+    lua_getglobal(l, TS_LUA_FUNCTION_SEND_REQUEST);
+    if (lua_type(l, -1) == LUA_TFUNCTION) {
+      if (lua_pcall(l, 0, 1, 0)) {
+        fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
+      }
+    }
 
-            break;
+    break;
 
-        case TS_EVENT_HTTP_READ_RESPONSE_HDR:
+  case TS_EVENT_HTTP_READ_RESPONSE_HDR:
 
-            lua_getglobal(l, TS_LUA_FUNCTION_READ_RESPONSE);
-            if (lua_type(l, -1) == LUA_TFUNCTION) {
-                if (lua_pcall(l, 0, 1, 0)) {
-                    fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
-                }
-            }
+    lua_getglobal(l, TS_LUA_FUNCTION_READ_RESPONSE);
+    if (lua_type(l, -1) == LUA_TFUNCTION) {
+      if (lua_pcall(l, 0, 1, 0)) {
+        fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
+      }
+    }
 
-            break;
+    break;
 
-        case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
+  case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
 
-            lua_getglobal(l, TS_LUA_FUNCTION_SEND_RESPONSE);
-            if (lua_type(l, -1) == LUA_TFUNCTION) {
-                if (lua_pcall(l, 0, 1, 0)) {
-                    fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
-                }
-            }
+    lua_getglobal(l, TS_LUA_FUNCTION_SEND_RESPONSE);
+    if (lua_type(l, -1) == LUA_TFUNCTION) {
+      if (lua_pcall(l, 0, 1, 0)) {
+        fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
+      }
+    }
 
-            break;
+    break;
 
-        case TS_EVENT_HTTP_TXN_CLOSE:
-            ts_lua_destroy_http_ctx(http_ctx);
-            TSContDestroy(contp);
-            break;
+  case TS_EVENT_HTTP_TXN_CLOSE:
+    ts_lua_destroy_http_ctx(http_ctx);
+    TSContDestroy(contp);
+    break;
 
-        default:
-            break;
-    }
+  default:
+    break;
+  }
 
-    TSMutexUnlock(main_ctx->mutexp);
-    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
-    return 0;
+  TSMutexUnlock(main_ctx->mutexp);
+  TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+  return 0;
 }
-


Mime
View raw message