You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ki...@apache.org on 2018/05/23 00:32:19 UTC
[trafficserver] branch master updated: support TSHttpSsnIdGet() in
lua plugin
This is an automated email from the ASF dual-hosted git repository.
kichan 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 e9961fc support TSHttpSsnIdGet() in lua plugin
e9961fc is described below
commit e9961fcb920987d2a8a53467e8511a3760afe056
Author: Kit Chan <ki...@apache.org>
AuthorDate: Mon May 21 21:48:27 2018 -0700
support TSHttpSsnIdGet() in lua plugin
---
doc/admin-guide/plugins/lua.en.rst | 20 ++++++++++++++++++++
plugins/lua/ts_lua_http.c | 17 +++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/doc/admin-guide/plugins/lua.en.rst b/doc/admin-guide/plugins/lua.en.rst
index b0002d0..daf8826 100644
--- a/doc/admin-guide/plugins/lua.en.rst
+++ b/doc/admin-guide/plugins/lua.en.rst
@@ -2373,6 +2373,26 @@ Here is an example:
`TOP <#ts-lua-plugin>`_
+ts.http.ssn_id
+--------------
+**syntax:** *ts.http.ssn_id()*
+
+**context:** do_remap/do_os_response or do_global_* or later
+
+**description:** This function can be used to tell id of a client session
+
+Here is an example:
+
+::
+
+ function do_global_read_request()
+ local id = ts.http.ssn_id()
+ ts.debug(id)
+ return 0
+ end
+
+`TOP <#ts-lua-plugin>`_
+
ts.http.is_internal_request
---------------------------
**syntax:** *ts.http.is_internal_request()*
diff --git a/plugins/lua/ts_lua_http.c b/plugins/lua/ts_lua_http.c
index daf6f53..d1f7723 100644
--- a/plugins/lua/ts_lua_http.c
+++ b/plugins/lua/ts_lua_http.c
@@ -87,6 +87,7 @@ static int ts_lua_http_server_push(lua_State *L);
static int ts_lua_http_is_websocket(lua_State *L);
static int ts_lua_http_get_plugin_tag(lua_State *L);
static int ts_lua_http_get_id(lua_State *L);
+static int ts_lua_http_get_ssn_id(lua_State *L);
static int ts_lua_http_is_internal_request(lua_State *L);
static int ts_lua_http_skip_remapping_set(lua_State *L);
static int ts_lua_http_transaction_count(lua_State *L);
@@ -214,6 +215,9 @@ ts_lua_inject_http_misc_api(lua_State *L)
lua_pushcfunction(L, ts_lua_http_get_id);
lua_setfield(L, -2, "id");
+ lua_pushcfunction(L, ts_lua_http_get_ssn_id);
+ lua_setfield(L, -2, "ssn_id");
+
lua_pushcfunction(L, ts_lua_http_is_internal_request);
lua_setfield(L, -2, "is_internal_request");
@@ -665,6 +669,19 @@ ts_lua_http_get_id(lua_State *L)
}
static int
+ts_lua_http_get_ssn_id(lua_State *L)
+{
+ ts_lua_http_ctx *http_ctx;
+
+ GET_HTTP_CONTEXT(http_ctx, L);
+
+ int64_t id = TSHttpSsnIdGet(TSHttpTxnSsnGet(http_ctx->txnp));
+ lua_pushnumber(L, id);
+
+ return 1;
+}
+
+static int
ts_lua_http_is_internal_request(lua_State *L)
{
ts_lua_http_ctx *http_ctx;
--
To stop receiving notification emails like this one, please contact
kichan@apache.org.