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 f4f2b04 add function for TSHttpTxnAborted f4f2b04 is described below commit f4f2b04654c80d8c41eb7705570e979d8ce13b39 Author: Kit Chan <kic...@apache.org> AuthorDate: Sat Jul 7 02:46:22 2018 -0700 add function for TSHttpTxnAborted --- doc/admin-guide/plugins/lua.en.rst | 22 +++++++++++++++++++++- plugins/lua/ts_lua_http.c | 20 ++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/doc/admin-guide/plugins/lua.en.rst b/doc/admin-guide/plugins/lua.en.rst index bf9eba3..48d9d90 100644 --- a/doc/admin-guide/plugins/lua.en.rst +++ b/doc/admin-guide/plugins/lua.en.rst @@ -2399,7 +2399,7 @@ ts.http.is_internal_request **context:** do_remap/do_os_response or do_global_* or later -**description:** This function can be used to tell is a request is internal or not +**description:** This function can be used to tell if a request is internal or not Here is an example: @@ -2413,6 +2413,26 @@ Here is an example: `TOP <#ts-lua-plugin>`_ +ts.http.is_aborted/ +------------------ +**syntax:** *ts.http.is_aborted()* + +**context:** do_remap/do_os_response or do_global_* or later + +**description:** This function can be used to tell if a request is aborted or not + +Here is an example: + +:: + + function do_global_read_request() + local aborted = ts.http.is_aborted() + ts.debug(aborted) + return 0 + end + +`TOP <#ts-lua-plugin>`_ + ts.http.transaction_count ------------------------- **syntax:** *ts.http.transaction_count()* diff --git a/plugins/lua/ts_lua_http.c b/plugins/lua/ts_lua_http.c index d1f7723..002fa62 100644 --- a/plugins/lua/ts_lua_http.c +++ b/plugins/lua/ts_lua_http.c @@ -89,6 +89,7 @@ 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_is_aborted(lua_State *L); static int ts_lua_http_skip_remapping_set(lua_State *L); static int ts_lua_http_transaction_count(lua_State *L); static int ts_lua_http_redirect_url_set(lua_State *L); @@ -221,6 +222,9 @@ ts_lua_inject_http_misc_api(lua_State *L) lua_pushcfunction(L, ts_lua_http_is_internal_request); lua_setfield(L, -2, "is_internal_request"); + lua_pushcfunction(L, ts_lua_http_is_aborted); + lua_setfield(L, -2, "is_aborted"); + lua_pushcfunction(L, ts_lua_http_skip_remapping_set); lua_setfield(L, -2, "skip_remapping_set"); @@ -698,6 +702,22 @@ ts_lua_http_is_internal_request(lua_State *L) } static int +ts_lua_http_is_aborted(lua_State *L) +{ + ts_lua_http_ctx *http_ctx; + + GET_HTTP_CONTEXT(http_ctx, L); + + if (TSHttpTxnAborted(http_ctx->txnp)) { + lua_pushnumber(L, 1); + } else { + lua_pushnumber(L, 0); + } + + return 1; +} + +static int ts_lua_http_skip_remapping_set(lua_State *L) { int action;