[
https://issues.apache.org/jira/browse/TS-4627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15359742#comment-15359742
]
ASF GitHub Bot commented on TS-4627:
------------------------------------
Github user jpeach commented on a diff in the pull request:
https://github.com/apache/trafficserver/pull/779#discussion_r69362522
--- Diff: plugins/experimental/ts_lua/ts_lua_http.c ---
@@ -29,9 +29,33 @@ typedef enum {
TS_LUA_CACHE_LOOKUP_SKIPPED
} TSLuaCacheLookupResult;
+typedef enum {
+ TS_LUA_SRVSTATE_STATE_UNDEFINED,
+ TS_LUA_SRVSTATE_ACTIVE_TIMEOUT,
+ TS_LUA_SRVSTATE_BAD_INCOMING_RESPONSE,
+ TS_LUA_SRVSTATE_CONNECTION_ALIVE,
+ TS_LUA_SRVSTATE_CONNECTION_CLOSED,
+ TS_LUA_SRVSTATE_CONNECTION_ERROR,
+ TS_LUA_SRVSTATE_INACTIVE_TIMEOUT,
+ TS_LUA_SRVSTATE_OPEN_RAW_ERROR,
+ TS_LUA_SRVSTATE_PARSE_ERROR,
+ TS_LUA_SRVSTATE_TRANSACTION_COMPLETE,
+ TS_LUA_SRVSTATE_CONGEST_CONTROL_CONGESTED_ON_F,
+ TS_LUA_SRVSTATE_CONGEST_CONTROL_CONGESTED_ON_M
+} TSLuaServerState;
+
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_server_state_string[] = {"TS_LUA_SRVSTATE_STATE_UNDEFINED",
"TS_LUA_SRVSTATE_ACTIVE_TIMEOUT"
--- End diff --
``const char *``
> ts_lua plugin - support TSRemapOSResponse() related functionality
> -----------------------------------------------------------------
>
> Key: TS-4627
> URL: https://issues.apache.org/jira/browse/TS-4627
> Project: Traffic Server
> Issue Type: Improvement
> Components: Lua, Plugins
> Reporter: Kit Chan
> Assignee: Kit Chan
> Fix For: 7.0.0
>
>
> I want to add enhancement to ts_lua so I can write script to take advantage
> of the TSRemapOSResponse() related functionality.
> here is one such example
> {code}
> function do_os_response()
> ts.debug('do_os_response')
> ts.http.enable_redirect(0)
> local st = ts.http.get_server_state()
> if st == TS_LUA_SRVSTATE_CONNECTION_ALIVE then
> ts.debug('alive')
> ts.http.enable_redirect(0)
> else
> ts.debug('not alive')
> ts.http.redirect_url_set('http://www.cnn.com')
> ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)
> end
> end
> function send_response()
> ts.debug('send_response')
> end
> {code}
> Basically it would allow me to do something when origin server fails to
> connect (such as DNS error, timeout, etc)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)