http-form-input #

form-input-nginx-module - NGINX module that reads HTTP POST and PUT request body encoded in "application/x-www-form-urlencoded" and parses the arguments into nginx variables.

Source: upstream source

Directives

set_form_input #

syntax: set_form_input 1 arg;  ·  context: http, server, location

Extracts a single field from an urlencoded POST/PUT request body into an nginx variable.

set_form_input_multi #

syntax: set_form_input_multi 1 arg;  ·  context: http, server, location

Parses all values of a repeated form field from the request body into an array-valued nginx variable.

Example

#nginx.conf

location /foo {
    # ensure client_max_body_size == client_body_buffer_size
    client_max_body_size 100k;
    client_body_buffer_size 100k;

    set_form_input $data;    # read "data" field into $data
    set_form_input $foo foo; # read "foo" field into $foo
}

location /bar {
    # ensure client_max_body_size == client_body_buffer_size
    client_max_body_size 1m;
    client_body_buffer_size 1m;

    set_form_input_multi $data; # read all "data" field into $data
    set_form_input_multi $foo data; # read all "data" field into $foo

    array_join ' ' $data; # now $data is an string
    array_join ' ' $foo;  # now $foo is an string
}

↑ back to index