trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [16/50] git commit: Implement LuaRemapRewrite
Date Tue, 12 Jun 2012 15:51:36 GMT
Implement LuaRemapRewrite


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/0d1c4c2e
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/0d1c4c2e
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/0d1c4c2e

Branch: refs/heads/jpeach/lua
Commit: 0d1c4c2e2f1e3f32ed974f24abae722ec08f7032
Parents: 58f5215
Author: James Peach <jpeach@apache.org>
Authored: Mon Apr 16 22:12:42 2012 -0700
Committer: James Peach <jpeach@apache.org>
Committed: Tue Jun 12 08:48:36 2012 -0700

----------------------------------------------------------------------
 plugins/lua/lapi.cc |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d1c4c2e/plugins/lua/lapi.cc
----------------------------------------------------------------------
diff --git a/plugins/lua/lapi.cc b/plugins/lua/lapi.cc
index 91350b1..92ed744 100644
--- a/plugins/lua/lapi.cc
+++ b/plugins/lua/lapi.cc
@@ -149,9 +149,31 @@ LuaRemapRedirect(lua_State * lua)
   return 1;
 }
 
+static int
+LuaRemapRewrite(lua_State * lua)
+{
+  LuaRemapRequest * rq;
+
+  rq = LuaRemapRequest::get(lua, 1);
+  luaL_checktype(lua, 2, LUA_TTABLE);
+
+  TSDebug("lua", "rewriting request %p", rq->rri);
+  lua_pushvalue(lua, 2);
+  LuaPopUrl(lua, rq->rri->requestBufp, rq->rri->requestUrl);
+  lua_pop(lua, 1);
+
+  // A rewrite updates the request URL but never terminates plugin chain evaluation.
+  rq->status = TSREMAP_DID_REMAP;
+
+  // Return true back to Lua-space.
+  lua_pushboolean(lua, 1);
+  return 1;
+}
+
 static const luaL_Reg RRI[] =
 {
   { "redirect", LuaRemapRedirect },
+  { "rewrite", LuaRemapRewrite },
   { NULL, NULL}
 };
 


Mime
View raw message