ASF Bugzilla – Attachment 28968 Details for
Bug 53064
Missing parsebody function in mod_lua
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for adding the parsebody function
lua_request.c.patch (text/plain), 1.95 KB, created by
Daniel Gruno
on 2012-06-20 11:06:30 UTC
(
hide
)
Description:
Patch for adding the parsebody function
Filename:
MIME Type:
Creator:
Daniel Gruno
Created:
2012-06-20 11:06:30 UTC
Size:
1.95 KB
patch
obsolete
>Index: modules/lua/lua_request.c >=================================================================== >--- modules/lua/lua_request.c (revision 1352013) >+++ modules/lua/lua_request.c (working copy) >@@ -164,6 +164,32 @@ > return 2; /* [table<string, string>, table<string, array<string>>] */ > } > >+/* r:parsebody() returning a lua table */ >+static int req_parsebody(lua_State *L) >+{ >+ apr_array_header_t *pairs; >+ apr_off_t len; >+ int res; >+ apr_size_t size; >+ char *buffer; >+ request_rec *r = ap_lua_check_request_rec(L, 1); >+ lua_newtable(L); >+ lua_newtable(L); /* [table, table] */ >+ res = ap_parse_form_data(r, NULL, &pairs, -1, MAX_STRING_LEN); /*XXX: Maybe increase this value? */ >+ if (res == OK) { >+ while(pairs && !apr_is_empty_array(pairs)) { >+ ap_form_pair_t *pair = (ap_form_pair_t *) apr_array_pop(pairs); >+ apr_brigade_length(pair->value, 1, &len); >+ size = (apr_size_t) len; >+ buffer = apr_palloc(r->pool, size + 1); >+ apr_brigade_flatten(pair->value, buffer, &size); >+ buffer[len] = 0; >+ req_aprtable2luatable_cb(L, pair->name, buffer); >+ } >+ } >+ return 2; /* [table<string, string>, table<string, array<string>>] */ >+} >+ > /* wrap ap_rputs as r:puts(String) */ > static int req_puts(lua_State *L) > { >@@ -625,6 +651,8 @@ > makefun(&req_context_document_root, APL_REQ_FUNTYPE_STRING, p)); > apr_hash_set(dispatch, "parseargs", APR_HASH_KEY_STRING, > makefun(&req_parseargs, APL_REQ_FUNTYPE_LUACFUN, p)); >+ apr_hash_set(dispatch, "parsebody", APR_HASH_KEY_STRING, >+ makefun(&req_parsebody, APL_REQ_FUNTYPE_LUACFUN, p)); > apr_hash_set(dispatch, "debug", APR_HASH_KEY_STRING, > makefun(&req_debug, APL_REQ_FUNTYPE_LUACFUN, p)); > apr_hash_set(dispatch, "info", APR_HASH_KEY_STRING, >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 53064
: 28968