webmcp

view framework/env/request/get_param_strings.lua @ 264:8aa38ddcc1b2

New configuration options "min_requests_per_connect" and "max_requests_per_connect"; Bugfix: Send headers added with request.add_header(...) also in case of 303 Redirect
author jbe
date Fri Mar 20 05:30:57 2015 +0100 (2015-03-20)
parents 8f028a0aa114
children 680777af0293
line source
1 --[[--
2 params =
3 request.get_param_strings{
4 method = method -- "GET", "POST", or nil to query both (POST has precedence)
5 include_internal = include_internal -- set to true to include also parameters starting with "_webmcp_" prefix
6 }
8 This function returns a table with all raw GET/POST parameters as strings or list of strings (except internal parameters like "_webmcp_path" or "_webmcp_id"). Modifications of the returned table have no side effects.
10 --]]--
12 local function merge_params(tbl, params_list, include)
13 for key, values in pairs(tbl) do
14 if not include and string.match(key, "^_webmcp_") then
15 -- do nothing
16 elseif string.match(key, "%[%]$") then
17 tbl[key] = table.new(values)
18 else
19 tbl[key] = values[1]
20 end
21 end
22 end
24 function request.get_param_strings(args)
25 local method = nil
26 local include = false
27 if args then
28 method = args.method
29 include = args.include
30 end
31 local t = {}
32 if not method then
33 merge_params(t, request._http_request.get_params_list, include)
34 merge_params(t, request._http_request.post_params_list, include)
35 elseif method == "GET" then
36 merge_params(t, request._http_request.get_params_list, include)
37 elseif method == "POST" then
38 merge_params(t, request._http_request.post_params_list, include)
39 else
40 error("Invalid method passed to request.get_param_strings{...}")
41 end
42 return t
43 end

Impressum / About Us