MCPcopy Create free account
hub / github.com/apache/trafficserver / ts_lua_http_cont_handler

Function ts_lua_http_cont_handler

plugins/lua/ts_lua_util.cc:1045–1279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1043}
1044
1045int
1046ts_lua_http_cont_handler(TSCont contp, TSEvent ev, void *edata)
1047{
1048 TSHttpTxn txnp;
1049 TSMBuffer bufp;
1050 TSMLoc hdr_loc;
1051 TSMLoc url_loc;
1052 int event, ret, rc, n, t;
1053 lua_State *L;
1054 ts_lua_http_ctx *http_ctx;
1055 ts_lua_main_ctx *main_ctx;
1056 ts_lua_cont_info *ci;
1057 ts_lua_coroutine *crt;
1058
1059 event = (int)ev;
1060 http_ctx = (ts_lua_http_ctx *)TSContDataGet(contp);
1061 ci = &http_ctx->cinfo;
1062 crt = &ci->routine;
1063
1064 main_ctx = crt->mctx;
1065 L = crt->lua;
1066
1067 txnp = http_ctx->txnp;
1068
1069 rc = ret = 0;
1070
1071 TSMutexLock(main_ctx->mutexp);
1072
1073 if (!http_ctx->client_request_bufp) {
1074 if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) == TS_SUCCESS) {
1075 http_ctx->client_request_bufp = bufp;
1076 http_ctx->client_request_hdrp = hdr_loc;
1077
1078 if (TSHttpHdrUrlGet(bufp, hdr_loc, &url_loc) == TS_SUCCESS) {
1079 http_ctx->client_request_url = url_loc;
1080 }
1081 }
1082 }
1083
1084 if (!http_ctx->client_request_hdrp) {
1085 TSMutexUnlock(main_ctx->mutexp);
1086
1087 TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
1088 return 0;
1089 }
1090
1091 ts_lua_set_cont_info(L, ci);
1092
1093 switch (event) {
1094 case TS_EVENT_HTTP_POST_REMAP:
1095
1096 lua_getglobal(L, TS_LUA_FUNCTION_POST_REMAP);
1097
1098 if (lua_type(L, -1) == LUA_TFUNCTION) {
1099 ret = lua_resume(L, 0);
1100 }
1101
1102 ts_lua_clear_http_ctx(http_ctx);

Callers

nothing calls this directly

Calls 11

TSContDataGetFunction · 0.85
TSMutexLockFunction · 0.85
TSHttpTxnClientReqGetFunction · 0.85
TSHttpHdrUrlGetFunction · 0.85
TSMutexUnlockFunction · 0.85
TSHttpTxnReenableFunction · 0.85
ts_lua_set_cont_infoFunction · 0.85
ts_lua_clear_http_ctxFunction · 0.85
ts_lua_destroy_http_ctxFunction · 0.85
TSErrorFunction · 0.50

Tested by

no test coverage detected