diff --git a/src/subsys/ngx_subsys_lua_input_filters.c.tt2 b/src/subsys/ngx_subsys_lua_input_filters.c.tt2 new file mode 100644 index 0000000..14cb8e7 --- /dev/null +++ b/src/subsys/ngx_subsys_lua_input_filters.c.tt2 @@ -0,0 +1,138 @@ + +/* + * Copyright (C) by OpenResty Inc. + */ + + +#ifndef DDEBUG +#define DDEBUG 0 +#endif +#include "ddebug.h" + + +#include "ngx_[% subsys %]_lua_common.h" + + +ngx_int_t +ngx_[% subsys %]_lua_read_bytes(ngx_buf_t *src, ngx_chain_t *buf_in, + size_t *rest, ssize_t bytes, ngx_log_t *log) +{ + if (bytes == 0) { + return NGX_ERROR; + } + + if ((size_t) bytes >= *rest) { + + buf_in->buf->last += *rest; + src->pos += *rest; + *rest = 0; + + return NGX_OK; + } + + /* bytes < *rest */ + + buf_in->buf->last += bytes; + src->pos += bytes; + *rest -= bytes; + + return NGX_AGAIN; +} + + +ngx_int_t +ngx_[% subsys %]_lua_read_all(ngx_buf_t *src, ngx_chain_t *buf_in, + ssize_t bytes, ngx_log_t *log) +{ + if (bytes == 0) { + return NGX_OK; + } + + buf_in->buf->last += bytes; + src->pos += bytes; + + return NGX_AGAIN; +} + + +ngx_int_t +ngx_[% subsys %]_lua_read_any(ngx_buf_t *src, ngx_chain_t *buf_in, size_t *max, + ssize_t bytes, ngx_log_t *log) +{ + if (bytes == 0) { + return NGX_ERROR; + } + + if (bytes >= (ssize_t) *max) { + bytes = (ssize_t) *max; + } + + buf_in->buf->last += bytes; + src->pos += bytes; + + return NGX_OK; +} + + +ngx_int_t +ngx_[% subsys %]_lua_read_line(ngx_buf_t *src, ngx_chain_t *buf_in, + ssize_t bytes, ngx_log_t *log) +{ + u_char *dst; + u_char c; +#if (NGX_DEBUG) + u_char *begin; +#endif + +#if (NGX_DEBUG) + begin = src->pos; +#endif + + if (bytes == 0) { + return NGX_ERROR; + } + + dd("already read: %p: %.*s", buf_in, + (int) (buf_in->buf->last - buf_in->buf->pos), buf_in->buf->pos); + + dd("data read: %.*s", (int) bytes, src->pos); + + dst = buf_in->buf->last; + + while (bytes--) { + + c = *src->pos++; + + switch (c) { + case '\n': + ngx_log_debug2(NGX_LOG_DEBUG_[% SUBSYS %], log, 0, + "[% log_prefix %]lua read the final line part: " + "\"%*s\"", src->pos - 1 - begin, begin); + + buf_in->buf->last = dst; + + dd("read a line: %p: %.*s", buf_in, + (int) (buf_in->buf->last - buf_in->buf->pos), buf_in->buf->pos); + + return NGX_OK; + + case '\r': + /* ignore it */ + break; + + default: + *dst++ = c; + break; + } + } + +#if (NGX_DEBUG) + ngx_log_debug2(NGX_LOG_DEBUG_[% SUBSYS %], log, 0, + "[% log_prefix %]lua read partial line data: %*s", + dst - begin, begin); +#endif + + buf_in->buf->last = dst; + + return NGX_AGAIN; +} diff --git a/src/subsys/ngx_subsys_lua_input_filters.h.tt2 b/src/subsys/ngx_subsys_lua_input_filters.h.tt2 new file mode 100644 index 0000000..84e27c2 --- /dev/null +++ b/src/subsys/ngx_subsys_lua_input_filters.h.tt2 @@ -0,0 +1,29 @@ + +/* + * Copyright (C) by OpenResty Inc. + */ + + +#ifndef _NGX_[% SUBSYS %]_LUA_INPUT_FILTERS_H_INCLUDED_ +#define _NGX_[% SUBSYS %]_LUA_INPUT_FILTERS_H_INCLUDED_ + + +#include "ngx_[% subsys %]_lua_common.h" + + +ngx_int_t ngx_[% subsys %]_lua_read_bytes(ngx_buf_t *src, ngx_chain_t *buf_in, + size_t *rest, ssize_t bytes, ngx_log_t *log); + +ngx_int_t ngx_[% subsys %]_lua_read_all(ngx_buf_t *src, ngx_chain_t *buf_in, + ssize_t bytes, ngx_log_t *log); + +ngx_int_t ngx_[% subsys %]_lua_read_any(ngx_buf_t *src, ngx_chain_t *buf_in, + size_t *max, ssize_t bytes, ngx_log_t *log); + +ngx_int_t ngx_[% subsys %]_lua_read_line(ngx_buf_t *src, ngx_chain_t *buf_in, + ssize_t bytes, ngx_log_t *log); + + +#endif /* _NGX_[% SUBSYS %]_LUA_INPUT_FILTERS_H_INCLUDED_ */ + +/* vi:set ft=c ts=4 sw=4 et fdm=marker: */ diff --git a/src/subsys/ngx_subsys_lua_socket_tcp.c.tt2 b/src/subsys/ngx_subsys_lua_socket_tcp.c.tt2 index 94df082..0f43fcd 100644 --- a/src/subsys/ngx_subsys_lua_socket_tcp.c.tt2 +++ b/src/subsys/ngx_subsys_lua_socket_tcp.c.tt2 @@ -11,6 +11,9 @@ #include "ngx_[% subsys %]_lua_socket_tcp.h" +[% IF http_subsys %] +#include "ngx_[% subsys %]_lua_input_filters.h" +[% END %] #include "ngx_[% subsys %]_lua_util.h" #include "ngx_[% subsys %]_lua_uthread.h" #include "ngx_[% subsys %]_lua_output.h" @@ -24,6 +27,9 @@ static int ngx_[% subsys %]_lua_socket_tcp_connect(lua_State *L); static int ngx_[% subsys %]_lua_socket_tcp_sslhandshake(lua_State *L); #endif static int ngx_[% subsys %]_lua_socket_tcp_receive(lua_State *L); +[% IF http_subsys %] +static int ngx_http_lua_socket_tcp_receiveany(lua_State *L); +[% END %] static int ngx_[% subsys %]_lua_socket_tcp_send(lua_State *L); static int ngx_[% subsys %]_lua_socket_tcp_close(lua_State *L); static int ngx_[% subsys %]_lua_socket_tcp_shutdown(lua_State *L); @@ -74,6 +80,8 @@ static int ngx_[% subsys %]_lua_socket_tcp_conn_retval_handler( lua_State *L); static void ngx_[% subsys %]_lua_socket_dummy_handler([% req_type %] *r, ngx_[% subsys %]_lua_socket_tcp_upstream_t *u); +static int ngx_[% subsys %]_lua_socket_tcp_receive_helper([% req_type %] *r, + ngx_[% subsys %]_lua_socket_tcp_upstream_t *u, lua_State *L); static ngx_int_t ngx_[% subsys %]_lua_socket_tcp_read([% req_type %] *r, ngx_[% subsys %]_lua_socket_tcp_upstream_t *u); static int ngx_[% subsys %]_lua_socket_tcp_receive_retval_handler( @@ -96,6 +104,7 @@ static int ngx_[% subsys %]_lua_socket_write_error_retval_handler( static ngx_int_t ngx_[% subsys %]_lua_socket_read_all(void *data, ssize_t bytes); static ngx_int_t ngx_[% subsys %]_lua_socket_read_until(void *data, ssize_t bytes); static ngx_int_t ngx_[% subsys %]_lua_socket_read_chunk(void *data, ssize_t bytes); +static ngx_int_t ngx_[% subsys %]_lua_socket_read_any(void *data, ssize_t bytes); static int ngx_[% subsys %]_lua_socket_tcp_receiveuntil(lua_State *L); static int ngx_[% subsys %]_lua_socket_receiveuntil_iterator(lua_State *L); static ngx_int_t ngx_[% subsys %]_lua_socket_compile_pattern(u_char *data, size_t len, @@ -267,11 +276,14 @@ ngx_[% subsys %]_lua_inject_socket_tcp_api(ngx_log_t *log, lua_State *L) /* {{{req socket object metatable */ lua_pushlightuserdata(L, ngx_[% subsys %]_lua_lightudata_mask( req_socket_metatable_key)); - lua_createtable(L, 0 /* narr */, 5 /* nrec */); + lua_createtable(L, 0 /* narr */, 6 /* nrec */); lua_pushcfunction(L, ngx_[% subsys %]_lua_socket_tcp_receive); lua_setfield(L, -2, "receive"); + lua_pushcfunction(L, ngx_[% subsys %]_lua_socket_tcp_receiveany); + lua_setfield(L, -2, "receiveany"); + lua_pushcfunction(L, ngx_[% subsys %]_lua_socket_tcp_receiveuntil); lua_setfield(L, -2, "receiveuntil"); @@ -1856,14 +1868,170 @@ ngx_[% subsys %]_lua_socket_tcp_conn_retval_handler([% req_type %] *r, } +static int +ngx_[% subsys %]_lua_socket_tcp_receive_helper([% req_type %] *r, + ngx_[% subsys %]_lua_socket_tcp_upstream_t *u, lua_State *L) +{ + ngx_int_t rc; + ngx_[% subsys %]_lua_ctx_t *lctx; + ngx_[% subsys %]_lua_co_ctx_t *coctx; + + u->input_filter_ctx = u; + + lctx = ngx_[% req_subsys %]_get_module_ctx(r, ngx_[% subsys %]_lua_module); + + if (u->bufs_in == NULL) { + u->bufs_in = + ngx_[% subsys %]_lua_chain_get_free_buf(r->connection->log, + r->pool, + &lctx->free_recv_bufs, + u->conf->buffer_size); + + if (u->bufs_in == NULL) { + return luaL_error(L, "no memory"); + } + + u->buf_in = u->bufs_in; + u->buffer = *u->buf_in->buf; + } + + dd("tcp receive: buf_in: %p, bufs_in: %p", u->buf_in, u->bufs_in); + + ngx_log_debug1(NGX_LOG_DEBUG_[% SUBSYS %], r->connection->log, 0, + "[% log_prefix %]lua tcp socket read timeout: %M", u->read_timeout); + + if (u->raw_downstream || u->body_downstream) { + r->read_event_handler = ngx_[% subsys %]_lua_req_socket_rev_handler; + } + + u->read_waiting = 0; + u->read_co_ctx = NULL; + + rc = ngx_[% subsys %]_lua_socket_tcp_read(r, u); + + if (rc == NGX_ERROR) { + dd("read failed: %d", (int) u->ft_type); + rc = ngx_[% subsys %]_lua_socket_tcp_receive_retval_handler(r, u, L); + dd("tcp receive retval returned: %d", (int) rc); + return rc; + } + + if (rc == NGX_OK) { + + ngx_log_debug0(NGX_LOG_DEBUG_[% SUBSYS %], r->connection->log, 0, + "[% log_prefix %]lua tcp socket receive done in a single run"); + + return ngx_[% subsys %]_lua_socket_tcp_receive_retval_handler(r, u, L); + } + + /* rc == NGX_AGAIN */ + + u->read_event_handler = ngx_[% subsys %]_lua_socket_read_handler; + + coctx = lctx->cur_co_ctx; + + ngx_[% subsys %]_lua_cleanup_pending_operation(coctx); + coctx->cleanup = ngx_[% subsys %]_lua_coctx_cleanup; + coctx->data = u; + + if (lctx->entered_content_phase) { + r->write_event_handler = ngx_[% subsys %]_lua_content_wev_handler; + + } else { + r->write_event_handler = ngx_[% subsys %]_core_run_phases; + } + + u->read_co_ctx = coctx; + u->read_waiting = 1; + u->read_prepare_retvals = ngx_[% subsys %]_lua_socket_tcp_receive_retval_handler; + + dd("setting data to %p, coctx:%p", u, coctx); + + if (u->raw_downstream || u->body_downstream) { + lctx->downstream = u; + } + + return lua_yield(L, 0); +} + + +[% IF http_subsys %] +static int +ngx_[% subsys %]_lua_socket_tcp_receiveany(lua_State *L) +{ + int n; + lua_Integer bytes; + ngx_http_request_t *r; + ngx_http_lua_loc_conf_t *llcf; + ngx_http_lua_socket_tcp_upstream_t *u; + + n = lua_gettop(L); + if (n != 2) { + return luaL_error(L, "expecting 2 arguments " + "(including the object), but got %d", n); + } + + r = ngx_http_lua_get_req(L); + if (r == NULL) { + return luaL_error(L, "no request found"); + } + + luaL_checktype(L, 1, LUA_TTABLE); + + lua_rawgeti(L, 1, SOCKET_CTX_INDEX); + u = lua_touserdata(L, -1); + + if (u == NULL || u->peer.connection == NULL || u->read_closed) { + + llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module); + + if (llcf->log_socket_errors) { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "[% log_prefix %]attempt to receive data on a closed " + "socket: u:%p, c:%p, ft:%d eof:%d", + u, u ? u->peer.connection : NULL, + u ? (int) u->ft_type : 0, u ? (int) u->eof : 0); + } + + lua_pushnil(L); + lua_pushliteral(L, "closed"); + return 2; + } + + if (u->request != r) { + return luaL_error(L, "bad request"); + } + + ngx_http_lua_socket_check_busy_connecting(r, u, L); + ngx_http_lua_socket_check_busy_reading(r, u, L); + + if (!lua_isnumber(L, 2)) { + return luaL_argerror(L, 2, "bad max argument"); + } + + bytes = lua_tointeger(L, 2); + if (bytes <= 0) { + return luaL_argerror(L, 2, "bad max argument"); + } + + u->input_filter = ngx_http_lua_socket_read_any; + u->rest = (size_t) bytes; + u->length = u->rest; + + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "[% log_prefix %]lua tcp socket calling receiveany() " + "method to read at most %uz bytes", u->rest); + + return ngx_http_lua_socket_tcp_receive_helper(r, u, L); +} +[% END %] + + static int ngx_[% subsys %]_lua_socket_tcp_receive(lua_State *L) { [% req_type %] *r; - ngx_int_t rc; - ngx_[% subsys %]_lua_ctx_t *ctx; ngx_[% subsys %]_lua_loc_conf_t *llcf; - ngx_[% subsys %]_lua_co_ctx_t *coctx; int n; ngx_str_t pat; lua_Integer bytes; @@ -1985,119 +2153,27 @@ ngx_[% subsys %]_lua_socket_tcp_receive(lua_State *L) u->rest = 0; } - u->input_filter_ctx = u; - - ctx = ngx_[% req_subsys %]_get_module_ctx(r, ngx_[% subsys %]_lua_module); - - if (u->bufs_in == NULL) { - u->bufs_in = - ngx_[% subsys %]_lua_chain_get_free_buf(r->connection->log, r->pool, - &ctx->free_recv_bufs, - u->conf->buffer_size); - - if (u->bufs_in == NULL) { - return luaL_error(L, "no memory"); - } - - u->buf_in = u->bufs_in; - u->buffer = *u->buf_in->buf; - } - - dd("tcp receive: buf_in: %p, bufs_in: %p", u->buf_in, u->bufs_in); - - if (u->raw_downstream || u->body_downstream) { - r->read_event_handler = ngx_[% subsys %]_lua_req_socket_rev_handler; - } - - u->read_waiting = 0; - u->read_co_ctx = NULL; - - rc = ngx_[% subsys %]_lua_socket_tcp_read(r, u); - - if (rc == NGX_ERROR) { - dd("read failed: %d", (int) u->ft_type); - rc = ngx_[% subsys %]_lua_socket_tcp_receive_retval_handler(r, u, L); - dd("tcp receive retval returned: %d", (int) rc); - return rc; - } - - if (rc == NGX_OK) { - - ngx_log_debug0(NGX_LOG_DEBUG_[% SUBSYS %], r->connection->log, 0, - "[% log_prefix %]lua tcp socket receive done in a single run"); - - return ngx_[% subsys %]_lua_socket_tcp_receive_retval_handler(r, u, L); - } - - /* rc == NGX_AGAIN */ - - u->read_event_handler = ngx_[% subsys %]_lua_socket_read_handler; - - coctx = ctx->cur_co_ctx; - - ngx_[% subsys %]_lua_cleanup_pending_operation(coctx); - coctx->cleanup = ngx_[% subsys %]_lua_coctx_cleanup; - coctx->data = u; - - if (ctx->entered_content_phase) { - r->write_event_handler = ngx_[% subsys %]_lua_content_wev_handler; - - } else { - r->write_event_handler = ngx_[% req_subsys %]_core_run_phases; - } - - u->read_co_ctx = coctx; - u->read_waiting = 1; - u->read_prepare_retvals = ngx_[% subsys %]_lua_socket_tcp_receive_retval_handler; - - dd("setting data to %p, coctx:%p", u, coctx); - - if (u->raw_downstream || u->body_downstream) { - ctx->downstream = u; - } - - return lua_yield(L, 0); + return ngx_http_lua_socket_tcp_receive_helper(r, u, L); } static ngx_int_t ngx_[% subsys %]_lua_socket_read_chunk(void *data, ssize_t bytes) { + ngx_int_t rc; ngx_[% subsys %]_lua_socket_tcp_upstream_t *u = data; - ngx_buf_t *b; -#if (NGX_DEBUG) - [% req_type %] *r; - - r = u->request; -#endif - - ngx_log_debug1(NGX_LOG_DEBUG_[% SUBSYS %], r->connection->log, 0, + ngx_log_debug1(NGX_LOG_DEBUG_[% SUBSYS %], u->request->connection->log, 0, "[% log_prefix %]lua tcp socket read chunk %z", bytes); - if (bytes == 0) { + rc = ngx_[% subsys %]_lua_read_bytes(&u->buffer, u->buf_in, &u->rest, + bytes, u->request->connection->log); + if (rc == NGX_ERROR) { u->ft_type |= NGX_[% SUBSYS %]_LUA_SOCKET_FT_CLOSED; return NGX_ERROR; } - b = &u->buffer; - - if (bytes >= (ssize_t) u->rest) { - - u->buf_in->buf->last += u->rest; - b->pos += u->rest; - u->rest = 0; - - return NGX_OK; - } - - /* bytes < u->rest */ - - u->buf_in->buf->last += bytes; - b->pos += bytes; - u->rest -= bytes; - - return NGX_AGAIN; + return rc; } @@ -2106,100 +2182,50 @@ ngx_[% subsys %]_lua_socket_read_all(void *data, ssize_t bytes) { ngx_[% subsys %]_lua_socket_tcp_upstream_t *u = data; - ngx_buf_t *b; -#if (NGX_DEBUG) - [% req_type %] *r; - - r = u->request; -#endif - - ngx_log_debug0(NGX_LOG_DEBUG_[% SUBSYS %], r->connection->log, 0, + ngx_log_debug0(NGX_LOG_DEBUG_[% SUBSYS %], u->request->connection->log, 0, "[% log_prefix %]lua tcp socket read all"); - - if (bytes == 0) { - return NGX_OK; - } - - b = &u->buffer; - - u->buf_in->buf->last += bytes; - b->pos += bytes; - - return NGX_AGAIN; + return ngx_[% subsys %]_lua_read_all(&u->buffer, u->buf_in, bytes, + u->request->connection->log); } static ngx_int_t ngx_[% subsys %]_lua_socket_read_line(void *data, ssize_t bytes) { + ngx_int_t rc; ngx_[% subsys %]_lua_socket_tcp_upstream_t *u = data; - ngx_buf_t *b; - u_char *dst; - u_char c; -#if (NGX_DEBUG) - u_char *begin; -#endif - ngx_log_debug0(NGX_LOG_DEBUG_[% SUBSYS %], u->request->connection->log, 0, "[% log_prefix %]lua tcp socket read line"); - if (bytes == 0) { + rc = ngx_[% subsys %]_lua_read_line(&u->buffer, u->buf_in, bytes, + u->request->connection->log); + if (rc == NGX_ERROR) { u->ft_type |= NGX_[% SUBSYS %]_LUA_SOCKET_FT_CLOSED; return NGX_ERROR; } - b = &u->buffer; - -#if (NGX_DEBUG) - begin = b->pos; -#endif - - dd("already read: %p: %.*s", u->buf_in, - (int) (u->buf_in->buf->last - u->buf_in->buf->pos), - u->buf_in->buf->pos); - - dd("data read: %.*s", (int) bytes, b->pos); - - dst = u->buf_in->buf->last; - - while (bytes--) { - - c = *b->pos++; - - switch (c) { - case '\n': - ngx_log_debug2(NGX_LOG_DEBUG_[% SUBSYS %], u->request->connection->log, 0, - "[% log_prefix %]lua tcp socket read the final line " - "part: \"%*s\"", b->pos - 1 - begin, begin); - - u->buf_in->buf->last = dst; + return rc; +} - dd("read a line: %p: %.*s", u->buf_in, - (int) (u->buf_in->buf->last - u->buf_in->buf->pos), - u->buf_in->buf->pos); - return NGX_OK; +static ngx_int_t +ngx_[% subsys %]_lua_socket_read_any(void *data, ssize_t bytes) +{ + ngx_int_t rc; + ngx_[% subsys %]_lua_socket_tcp_upstream_t *u = data; - case '\r': - /* ignore it */ - break; + ngx_log_debug0(NGX_LOG_DEBUG_[% SUBSYS %], u->request->connection->log, 0, + "[% log_prefix %]lua tcp socket read any"); - default: - *dst++ = c; - break; - } + rc = ngx_[% subsys %]_lua_read_any(&u->buffer, u->buf_in, &u->rest, bytes, + u->request->connection->log); + if (rc == NGX_ERROR) { + u->ft_type |= NGX_[% SUBSYS %]_LUA_SOCKET_FT_CLOSED; + return NGX_ERROR; } -#if (NGX_DEBUG) - ngx_log_debug2(NGX_LOG_DEBUG_[% SUBSYS %], u->request->connection->log, 0, - "[% log_prefix %]lua tcp socket read partial line data: %*s", - dst - begin, begin); -#endif - - u->buf_in->buf->last = dst; - - return NGX_AGAIN; + return rc; } diff --git a/src/subsys/ngx_subsys_lua_util.c.tt2 b/src/subsys/ngx_subsys_lua_util.c.tt2 index d6f093a..b0345b1 100644 --- a/src/subsys/ngx_subsys_lua_util.c.tt2 +++ b/src/subsys/ngx_subsys_lua_util.c.tt2 @@ -148,7 +148,9 @@ static ngx_int_t static lua_State *ngx_[% subsys %]_lua_new_state(lua_State *parent_vm, ngx_cycle_t *cycle, ngx_[% subsys %]_lua_main_conf_t *lmcf, ngx_log_t *log); static int ngx_[% subsys %]_lua_get_raw_phase_context(lua_State *L); +[% IF stream_subsys %] static int ngx_[% subsys %]_lua_req_socket(lua_State *L); +[% END %] #ifndef LUA_PATH_SEP @@ -2294,17 +2296,13 @@ done: } +[% IF stream_subsys %] static int -ngx_[% subsys%]_lua_req_socket(lua_State *L) +ngx_[% subsys %]_lua_req_socket(lua_State *L) { -[% IF stream_subsys %] ngx_stream_lua_request_t *r; ngx_stream_lua_ctx_t *ctx; -[% END %] -[% IF http_subsys %] - return ngx_http_lua_req_socket_tcp(L); -[% ELSIF stream_subsys %] r = ngx_stream_lua_get_req(L); ctx = ngx_stream_lua_get_module_ctx(r, ngx_stream_lua_module); @@ -2325,12 +2323,12 @@ ngx_[% subsys%]_lua_req_socket(lua_State *L) /* shouldn't happen */ ngx_log_error(NGX_LOG_EMERG, r->connection->log, 0, "unexpected connection type: %d", r->connection->type); -[% END %] ngx_stream_lua_assert(0); return luaL_error(L, "unexpected connection type"); } +[% END %] void @@ -2340,10 +2338,11 @@ ngx_[% subsys %]_lua_inject_req_api(ngx_log_t *log, lua_State *L) lua_createtable(L, 0 /* narr */, 24 /* nrec */); /* .req */ +[% IF stream_subsys %] lua_pushcfunction(L, ngx_[% subsys %]_lua_req_socket); lua_setfield(L, -2, "socket"); -[% IF http_subsys %] +[% ELSIF http_subsys %] ngx_[% subsys %]_lua_inject_req_header_api(L); ngx_[% subsys %]_lua_inject_req_uri_api(log, L); ngx_[% subsys %]_lua_inject_req_args_api(L);