# HG changeset patch # User jbe # Date 1427237654 -3600 # Node ID 061ee100f1c1db606af2dca704a7d0550e5c09cf # Parent f59376630f47d2e934ec929819e72628f7f8c665 Bugfix: respect "index" argument to request.get_param{...} function; Allow access to metadata of POST fields in request.get_param{...} diff -r f59376630f47 -r 061ee100f1c1 framework/env/request/get_param.lua --- a/framework/env/request/get_param.lua Tue Mar 24 21:40:46 2015 +0100 +++ b/framework/env/request/get_param.lua Tue Mar 24 23:54:14 2015 +0100 @@ -1,10 +1,11 @@ --[[-- -value = -- value of GET/POST parameter, or value list if multiple == true +value = -- value of GET/POST parameter, or value list if multiple == true request.get_param{ - method = method, -- "GET", "POST", or nil to query both (POST has precedence) - name = name, -- field name - index = index, -- defaults to 1 to get first occurrence, only applicable if multiple == false - multiple = multiple -- boolean to indicate whether to return a single value or a value list + method = method, -- "GET", "POST", or nil to query both (POST has precedence) + name = name, -- field name + index = index, -- defaults to 1 to get first occurrence, only applicable if multiple == false + multiple = multiple, -- boolean to indicate whether to return a single value or a value list + meta = meta -- set to true to get metadata (table with "file_name" and "content_type") } Reads GET/POST parameters directly from the underlaying request. @@ -13,20 +14,33 @@ function request.get_param(args) local param_list - if args.method == "GET" then - param_list = request._http_request.get_params_list[args.name] - elseif args.method == "POST" then - param_list = request._http_request.post_params_list[args.name] - elseif not args.method then - param_list = request._http_request.post_params_list[args.name] - if not param_list[index or 1] then + if args.metadata then + if args.method == "GET" then + param_list = request._http_request.get_metadata_list[args.name] + elseif args.method == "POST" then + param_list = request._http_request.post_metadata_list[args.name] + elseif not args.method then + param_list = request._http_request.post_metadata_list[args.name] + if not param_list[args.index or 1] then + param_list = request._http_request.get_metadata_list[args.name] + end + end + else + if args.method == "GET" then param_list = request._http_request.get_params_list[args.name] + elseif args.method == "POST" then + param_list = request._http_request.post_params_list[args.name] + elseif not args.method then + param_list = request._http_request.post_params_list[args.name] + if not param_list[args.index or 1] then + param_list = request._http_request.get_params_list[args.name] + end end end if args.multiple then return param_list else - return param_list[index or 1] + return param_list[args.index or 1] end end