}
if (!sl) {
hlua_pusherror(L, "Lua applet http '%s': Failed to create response.\n",
- luactx->appctx->rule->arg.hlua_rule->fcn->name);
+ luactx->appctx->applet->name);
WILL_LJMP(lua_error(L));
}
sl->info.res.status = http_ctx->status;
/* Get the array associated to the field "response" in the object AppletHTTP. */
if (lua_getfield(L, 1, "response") != LUA_TTABLE) {
hlua_pusherror(L, "Lua applet http '%s': AppletHTTP['response'] missing.\n",
- luactx->appctx->rule->arg.hlua_rule->fcn->name);
+ luactx->appctx->applet->name);
WILL_LJMP(lua_error(L));
}
/* We expect a string as -2. */
if (lua_type(L, -2) != LUA_TSTRING) {
hlua_pusherror(L, "Lua applet http '%s': AppletHTTP['response'][] element must be a string. got %s.\n",
- luactx->appctx->rule->arg.hlua_rule->fcn->name,
+ luactx->appctx->applet->name,
lua_typename(L, lua_type(L, -2)));
WILL_LJMP(lua_error(L));
}
/* We expect an array as -1. */
if (lua_type(L, -1) != LUA_TTABLE) {
hlua_pusherror(L, "Lua applet http '%s': AppletHTTP['response']['%s'] element must be an table. got %s.\n",
- luactx->appctx->rule->arg.hlua_rule->fcn->name,
+ luactx->appctx->applet->name,
name,
lua_typename(L, lua_type(L, -1)));
WILL_LJMP(lua_error(L));
/* We expect a number as -2. */
if (lua_type(L, -2) != LUA_TNUMBER) {
hlua_pusherror(L, "Lua applet http '%s': AppletHTTP['response']['%s'][] element must be a number. got %s.\n",
- luactx->appctx->rule->arg.hlua_rule->fcn->name,
+ luactx->appctx->applet->name,
name,
lua_typename(L, lua_type(L, -2)));
WILL_LJMP(lua_error(L));
/* We expect a string as -2. */
if (lua_type(L, -1) != LUA_TSTRING) {
hlua_pusherror(L, "Lua applet http '%s': AppletHTTP['response']['%s'][%d] element must be a string. got %s.\n",
- luactx->appctx->rule->arg.hlua_rule->fcn->name,
+ luactx->appctx->applet->name,
name, id,
lua_typename(L, lua_type(L, -1)));
WILL_LJMP(lua_error(L));
ret = h1_parse_xfer_enc_header(&h1m, ist2(value, vlen));
if (ret < 0) {
hlua_pusherror(L, "Lua applet http '%s': Invalid '%s' header.\n",
- luactx->appctx->rule->arg.hlua_rule->fcn->name,
+ luactx->appctx->applet->name,
name);
WILL_LJMP(lua_error(L));
}
ret = http_parse_cont_len_header(&v, &body_len, (h1m.flags & H1_MF_CLEN));
if (ret < 0) {
hlua_pusherror(L, "Lua applet http '%s': Invalid '%s' header.\n",
- luactx->appctx->rule->arg.hlua_rule->fcn->name,
+ luactx->appctx->applet->name,
name);
WILL_LJMP(lua_error(L));
}
/* Add a new header */
if (!htx_add_header(htx, ist2(name, nlen), ist2(value, vlen))) {
hlua_pusherror(L, "Lua applet http '%s': Failed to add header '%s' in the response.\n",
- luactx->appctx->rule->arg.hlua_rule->fcn->name,
+ luactx->appctx->applet->name,
name);
WILL_LJMP(lua_error(L));
}
sl->flags |= (HTX_SL_F_XFER_ENC|H1_MF_CHNK|H1_MF_XFER_LEN);
if (!htx_add_header(htx, ist("transfer-encoding"), ist("chunked"))) {
hlua_pusherror(L, "Lua applet http '%s': Failed to add header 'transfer-encoding' in the response.\n",
- luactx->appctx->rule->arg.hlua_rule->fcn->name);
+ luactx->appctx->applet->name);
WILL_LJMP(lua_error(L));
}
}
/* Finalize headers. */
if (!htx_add_endof(htx, HTX_BLK_EOH)) {
hlua_pusherror(L, "Lua applet http '%s': Failed create the response.\n",
- luactx->appctx->rule->arg.hlua_rule->fcn->name);
+ luactx->appctx->applet->name);
WILL_LJMP(lua_error(L));
}
hlua = pool_alloc(pool_head_hlua);
if (!hlua) {
SEND_ERR(strm->be, "Lua applet tcp '%s': out of memory.\n",
- ctx->rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
return -1;
}
HLUA_INIT(hlua);
task = task_new_here();
if (!task) {
SEND_ERR(strm->be, "Lua applet tcp '%s': out of memory.\n",
- ctx->rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
return -1;
}
task->nice = 0;
*/
if (!hlua_ctx_init(hlua, fcn_ref_to_stack_id(ctx->rule->arg.hlua_rule->fcn), task)) {
SEND_ERR(strm->be, "Lua applet tcp '%s': can't initialize Lua context.\n",
- ctx->rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
return -1;
}
else
error = "critical error";
SEND_ERR(strm->be, "Lua applet tcp '%s': %s.\n",
- ctx->rule->arg.hlua_rule->fcn->name, error);
+ ctx->applet->name, error);
hlua_unlock(hlua);
return -1;
}
/* Check stack available size. */
if (!lua_checkstack(hlua->T, 1)) {
SEND_ERR(strm->be, "Lua applet tcp '%s': full stack.\n",
- ctx->rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
RESET_SAFE_LJMP(hlua);
return -1;
}
/* Create and and push object stream in the stack. */
if (!hlua_applet_tcp_new(hlua->T, ctx)) {
SEND_ERR(strm->be, "Lua applet tcp '%s': full stack.\n",
- ctx->rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
RESET_SAFE_LJMP(hlua);
return -1;
}
for (arg = ctx->rule->arg.hlua_rule->args; arg && *arg; arg++) {
if (!lua_checkstack(hlua->T, 1)) {
SEND_ERR(strm->be, "Lua applet tcp '%s': full stack.\n",
- ctx->rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
RESET_SAFE_LJMP(hlua);
return -1;
}
struct hlua_tcp_ctx *tcp_ctx = ctx->svcctx;
struct stconn *sc = appctx_sc(ctx);
struct stream *strm = __sc_strm(sc);
- struct act_rule *rule = ctx->rule;
struct proxy *px = strm->be;
struct hlua *hlua = tcp_ctx->hlua;
int yield = 0;
/* Display log. */
hlua_lock(hlua);
SEND_ERR(px, "Lua applet tcp '%s': %s.\n",
- rule->arg.hlua_rule->fcn->name, hlua_tostring_safe(hlua->T, -1));
+ ctx->applet->name, hlua_tostring_safe(hlua->T, -1));
lua_pop(hlua->T, 1);
hlua_unlock(hlua);
goto error;
case HLUA_E_ETMOUT:
SEND_ERR(px, "Lua applet tcp '%s': execution timeout.\n",
- rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
goto error;
case HLUA_E_BTMOUT:
SEND_ERR(px, "Lua applet tcp '%s': burst timeout.\n",
- rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
goto error;
case HLUA_E_NOMEM:
SEND_ERR(px, "Lua applet tcp '%s': out of memory error.\n",
- rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
goto error;
case HLUA_E_YIELD: /* unexpected */
SEND_ERR(px, "Lua applet tcp '%s': yield not allowed.\n",
- rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
goto error;
case HLUA_E_ERR:
/* Display log. */
SEND_ERR(px, "Lua applet tcp '%s' return an unknown error.\n",
- rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
goto error;
default:
hlua = pool_alloc(pool_head_hlua);
if (!hlua) {
SEND_ERR(strm->be, "Lua applet http '%s': out of memory.\n",
- ctx->rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
return -1;
}
HLUA_INIT(hlua);
task = task_new_here();
if (!task) {
SEND_ERR(strm->be, "Lua applet http '%s': out of memory.\n",
- ctx->rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
return -1;
}
task->nice = 0;
*/
if (!hlua_ctx_init(hlua, fcn_ref_to_stack_id(ctx->rule->arg.hlua_rule->fcn), task)) {
SEND_ERR(strm->be, "Lua applet http '%s': can't initialize Lua context.\n",
- ctx->rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
return -1;
}
else
error = "critical error";
SEND_ERR(strm->be, "Lua applet http '%s': %s.\n",
- ctx->rule->arg.hlua_rule->fcn->name, error);
+ ctx->applet->name, error);
hlua_unlock(hlua);
return -1;
}
/* Check stack available size. */
if (!lua_checkstack(hlua->T, 1)) {
SEND_ERR(strm->be, "Lua applet http '%s': full stack.\n",
- ctx->rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
RESET_SAFE_LJMP(hlua);
return -1;
}
/* Create and and push object stream in the stack. */
if (!hlua_applet_http_new(hlua->T, ctx)) {
SEND_ERR(strm->be, "Lua applet http '%s': full stack.\n",
- ctx->rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
RESET_SAFE_LJMP(hlua);
return -1;
}
for (arg = ctx->rule->arg.hlua_rule->args; arg && *arg; arg++) {
if (!lua_checkstack(hlua->T, 1)) {
SEND_ERR(strm->be, "Lua applet http '%s': full stack.\n",
- ctx->rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
RESET_SAFE_LJMP(hlua);
return -1;
}
struct stream *strm = __sc_strm(sc);
struct channel *req = sc_oc(sc);
struct channel *res = sc_ic(sc);
- struct act_rule *rule = ctx->rule;
struct proxy *px = strm->be;
struct hlua *hlua = http_ctx->hlua;
struct htx *req_htx, *res_htx;
/* Display log. */
hlua_lock(hlua);
SEND_ERR(px, "Lua applet http '%s': %s.\n",
- rule->arg.hlua_rule->fcn->name, hlua_tostring_safe(hlua->T, -1));
+ ctx->applet->name, hlua_tostring_safe(hlua->T, -1));
lua_pop(hlua->T, 1);
hlua_unlock(hlua);
goto error;
case HLUA_E_ETMOUT:
SEND_ERR(px, "Lua applet http '%s': execution timeout.\n",
- rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
goto error;
case HLUA_E_BTMOUT:
SEND_ERR(px, "Lua applet http '%s': burst timeout.\n",
- rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
goto error;
case HLUA_E_NOMEM:
SEND_ERR(px, "Lua applet http '%s': out of memory error.\n",
- rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
goto error;
case HLUA_E_YIELD: /* unexpected */
SEND_ERR(px, "Lua applet http '%s': yield not allowed.\n",
- rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
goto error;
case HLUA_E_ERR:
/* Display log. */
SEND_ERR(px, "Lua applet http '%s' return an unknown error.\n",
- rule->arg.hlua_rule->fcn->name);
+ ctx->applet->name);
goto error;
default: