View | Details | Raw Unified | Return to bug 62369
Collapse All | Expand All

(-)/home/max/httpd-2.4.33/modules/lua/lua_request.c (-2 / +36 lines)
Lines 46-51 Link Here
46
typedef int (*req_field_int_f) (request_rec * r);
46
typedef int (*req_field_int_f) (request_rec * r);
47
typedef req_table_t *(*req_field_apr_table_f) (request_rec * r);
47
typedef req_table_t *(*req_field_apr_table_f) (request_rec * r);
48
48
49
static void
50
argstr_to_table(char *str, apr_table_t *parms)
51
{
52
    char *key;
53
    char *value;
54
    char *strtok_state;
55
56
    if (str == NULL) {
57
        return;
58
    }
59
60
    key = apr_strtok(str, "&", &strtok_state);
61
    while (key) {
62
        value = strchr(key, '=');
63
        if (value) {
64
            *value = '\0';      /* Split the string in two */
65
            value++;            /* Skip passed the = */
66
        }
67
        else {
68
            value = "1";
69
        }
70
        ap_unescape_url(key);
71
        ap_unescape_url(value);
72
        apr_table_add(parms, key, value);
73
        key = apr_strtok(NULL, "&", &strtok_state);
74
    }
75
}
76
77
AP_DECLARE(void) ap_lua_args_to_table(request_rec *r, apr_table_t **table)
78
{
79
    apr_table_t *t = apr_table_make(r->pool, 10);
80
    argstr_to_table(apr_pstrdup(r->pool, r->args), t);
81
    *table = t;
82
}
49
83
50
void ap_lua_rstack_dump(lua_State *L, request_rec *r, const char *msg)
84
void ap_lua_rstack_dump(lua_State *L, request_rec *r, const char *msg)
51
{
85
{
Lines 314-320 Link Here
314
    request_rec *r = ap_lua_check_request_rec(L, 1);
348
    request_rec *r = ap_lua_check_request_rec(L, 1);
315
    lua_newtable(L);
349
    lua_newtable(L);
316
    lua_newtable(L);            /* [table, table] */
350
    lua_newtable(L);            /* [table, table] */
317
    ap_args_to_table(r, &form_table);
351
    ap_lua_args_to_table(r, &form_table);
318
    apr_table_do(req_aprtable2luatable_cb, L, form_table, NULL);
352
    apr_table_do(req_aprtable2luatable_cb, L, form_table, NULL);
319
    return 2;                   /* [table<string, string>, table<string, array<string>>] */
353
    return 2;                   /* [table<string, string>, table<string, array<string>>] */
320
}
354
}
Lines 497-503 Link Here
497
    const char *name = luaL_checkstring(L, 2);
531
    const char *name = luaL_checkstring(L, 2);
498
    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01485) "adding output filter %s",
532
    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01485) "adding output filter %s",
499
                  name);
533
                  name);
500
    ap_add_output_filter(name, L, r, r->connection);
534
    ap_add_output_filter(name, NULL, r, r->connection);
501
    return 0;
535
    return 0;
502
}
536
}
503
537

Return to bug 62369