mirror of
https://github.com/apache/httpd.git
synced 2025-08-05 16:55:50 +03:00
add r/o iterable tables
The current apr tables exposed support get/set but we cannot get the keys or iterate. add _table() alternatives git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1872455 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -307,6 +307,40 @@ static apr_status_t lua_write_body(request_rec *r, apr_file_t *file, apr_off_t *
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* expose apr_table as (r/o) lua table */
|
||||
static int req_aprtable2luatable(lua_State *L, apr_table_t *t)
|
||||
{
|
||||
lua_newtable(L);
|
||||
lua_newtable(L); /* [table, table] */
|
||||
apr_table_do(req_aprtable2luatable_cb, L, t, NULL);
|
||||
return 2; /* [table<string, string>, table<string, array<string>>] */
|
||||
}
|
||||
|
||||
static int req_headers_in_table(lua_State *L)
|
||||
{
|
||||
request_rec *r = ap_lua_check_request_rec(L, 1);
|
||||
return req_aprtable2luatable(L, r->headers_in);
|
||||
}
|
||||
static int req_headers_out_table(lua_State *L)
|
||||
{
|
||||
request_rec *r = ap_lua_check_request_rec(L, 1);
|
||||
return req_aprtable2luatable(L, r->headers_out);
|
||||
}
|
||||
static int req_err_headers_out_table(lua_State *L)
|
||||
{
|
||||
request_rec *r = ap_lua_check_request_rec(L, 1);
|
||||
return req_aprtable2luatable(L, r->err_headers_out);
|
||||
}
|
||||
static int req_notes_table(lua_State *L)
|
||||
{
|
||||
request_rec *r = ap_lua_check_request_rec(L, 1);
|
||||
return req_aprtable2luatable(L, r->notes);
|
||||
}
|
||||
static int req_subprocess_env_table(lua_State *L)
|
||||
{
|
||||
request_rec *r = ap_lua_check_request_rec(L, 1);
|
||||
return req_aprtable2luatable(L, r->subprocess_env);
|
||||
}
|
||||
/* r:parseargs() returning a lua table */
|
||||
static int req_parseargs(lua_State *L)
|
||||
{
|
||||
@@ -2814,14 +2848,24 @@ void ap_lua_load_request_lmodule(lua_State *L, apr_pool_t *p)
|
||||
makefun(&req_proxyreq_field, APL_REQ_FUNTYPE_STRING, p));
|
||||
apr_hash_set(dispatch, "headers_in", APR_HASH_KEY_STRING,
|
||||
makefun(&req_headers_in, APL_REQ_FUNTYPE_TABLE, p));
|
||||
apr_hash_set(dispatch, "headers_in_table", APR_HASH_KEY_STRING,
|
||||
makefun(&req_headers_in_table, APL_REQ_FUNTYPE_LUACFUN, p));
|
||||
apr_hash_set(dispatch, "headers_out", APR_HASH_KEY_STRING,
|
||||
makefun(&req_headers_out, APL_REQ_FUNTYPE_TABLE, p));
|
||||
apr_hash_set(dispatch, "headers_out_table", APR_HASH_KEY_STRING,
|
||||
makefun(&req_headers_out_table, APL_REQ_FUNTYPE_LUACFUN, p));
|
||||
apr_hash_set(dispatch, "err_headers_out", APR_HASH_KEY_STRING,
|
||||
makefun(&req_err_headers_out, APL_REQ_FUNTYPE_TABLE, p));
|
||||
apr_hash_set(dispatch, "err_headers_out_table", APR_HASH_KEY_STRING,
|
||||
makefun(&req_err_headers_out_table, APL_REQ_FUNTYPE_LUACFUN, p));
|
||||
apr_hash_set(dispatch, "notes", APR_HASH_KEY_STRING,
|
||||
makefun(&req_notes, APL_REQ_FUNTYPE_TABLE, p));
|
||||
apr_hash_set(dispatch, "notes_table", APR_HASH_KEY_STRING,
|
||||
makefun(&req_notes_table, APL_REQ_FUNTYPE_LUACFUN, p));
|
||||
apr_hash_set(dispatch, "subprocess_env", APR_HASH_KEY_STRING,
|
||||
makefun(&req_subprocess_env, APL_REQ_FUNTYPE_TABLE, p));
|
||||
apr_hash_set(dispatch, "subprocess_env_table", APR_HASH_KEY_STRING,
|
||||
makefun(&req_subprocess_env_table, APL_REQ_FUNTYPE_LUACFUN, p));
|
||||
apr_hash_set(dispatch, "flush", APR_HASH_KEY_STRING,
|
||||
makefun(&lua_ap_rflush, APL_REQ_FUNTYPE_LUACFUN, p));
|
||||
apr_hash_set(dispatch, "port", APR_HASH_KEY_STRING,
|
||||
|
Reference in New Issue
Block a user