ngx.req.get_post_args Issue

Nginx User nginx at nginxuser.net
Sun Nov 6 07:12:28 UTC 2011


On 6 November 2011 05:38, agentzh <agentzh at gmail.com> wrote:
> Multipart form format is not supported in ngx.req.get_post_args. Only
> urlencoded format is supported for now. I'll make this clear in the
> documentation.

Thanks for the clarification..

As I need to have a mix of both types, I have combined three files
from the cgilua package into one module (cgilua_module) and using this
instead.

Handles both multipart and urlencoded formats and outputs a table of
key/pair values. (Also has "application/xml", "text/xml", and
"text/plain" under the POST request handler. Not yet sure where these
fit in and just left them in)

My code (work in progress) is now
-************************
          START
-************************
local ngx_cgi = require "cgilua_module"
if ngx.var.request_method == "POST" then
       ngx.req.read_body()
       local post_args = ngx_cgi.get_post_args()
       for my_key, v in pairs( post_args ) do
               if type(v) == "table" then
                       my_arg = table.concat(v, " ")
               else
                       my_arg = v
               end
               regex_rules.log_alert("Alert:- " .. my_key .. " ::: " .. my_arg)
       end
end
-************************
          END
-************************

Since cgilua has a permissive license, perhaps this, although in lua
and not C, will be helpful in extending the coverage of
ngx.req.get_post_args to multipart encoded forms.

Cheers!



More information about the nginx mailing list