• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H16-May-2016-643444

t/H16-May-2016-22,40015,972

util/H16-May-2016-169119

.gitignoreH A D16-May-2016699 7069

README.mdH A D16-May-20165.2 KiB165121

configH A D16-May-20161.2 KiB3832

valgrind.suppressH A D16-May-2016515 3231

README.md

1Name
2====
3
4form-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.
5
6Table of Contents
7=================
8
9* [Name](#name)
10* [Description](#description)
11* [Installation](#installation)
12    * [Building as a dynamic module](#building-as-a-dynamic-module)
13* [Usage](#usage)
14* [Limitations](#limitations)
15* [Compatibility](#compatibility)
16* [Copyright & License](#copyright--license)
17
18Description
19===========
20
21This is a nginx module that reads HTTP POST and PUT request body encoded
22in "application/x-www-form-urlencoded", and parse the arguments in
23request body into nginx variables.
24
25This module depends on the ngx_devel_kit (NDK) module.
26
27Installation
28============
29
30Grab the nginx source code from [nginx.org](http://nginx.org/), for example,
31the version 1.9.7 (see [nginx compatibility](#compatibility)), and then build the source with this module:
32
33```bash
34wget 'http://nginx.org/download/nginx-1.9.7.tar.gz'
35tar -xzvf nginx-1.9.7.tar.gz
36cd nginx-1.9.7/
37
38./configure --add-module=/path/to/ngx_devel_kit \
39    --add-module=/path/to/form-input-nginx-module
40
41make -j2
42make install
43```
44
45Download the latest version of the release tarball of this module from [form-input-nginx-module file list](http://github.com/calio/form-input-nginx-module/tags), and the latest tarball for [ngx_devel_kit](https://github.com/simpl/ngx_devel_kit) from its [file list](https://github.com/simpl/ngx_devel_kit/tags).
46
47Building as a dynamic module
48----------------------------
49
50Starting from NGINX 1.9.11, you can also compile this module as a dynamic module, by using the `--add-dynamic-module=PATH` option instead of `--add-module=PATH` on the
51`./configure` command line above. And then you can explicitly load the module in your `nginx.conf` via the [load_module](http://nginx.org/en/docs/ngx_core_module.html#load_module)
52directive, for example,
53
54```nginx
55load_module /path/to/modules/ndk_http_module.so;  # assuming NDK is built as a dynamic module too
56load_module /path/to/modules/ngx_http_form_input_module.so;
57```
58
59[Back to TOC](#table-of-contents)
60
61Usage
62=====
63
64```nginx
65set_form_input $variable;
66set_form_input $variable argument;
67
68set_form_input_multi $variable;
69set_form_input_multi $variable argument;
70```
71
72example:
73
74```nginx
75#nginx.conf
76
77location /foo {
78    # ensure client_max_body_size == client_body_buffer_size
79    client_max_body_size 100k;
80    client_body_buffer_size 100k;
81
82    set_form_input $data;    # read "data" field into $data
83    set_form_input $foo foo; # read "foo" field into $foo
84}
85
86location /bar {
87    # ensure client_max_body_size == client_body_buffer_size
88    client_max_body_size 1m;
89    client_body_buffer_size 1m;
90
91    set_form_input_multi $data; # read all "data" field into $data
92    set_form_input_multi $foo data; # read all "data" field into $foo
93
94    array_join ' ' $data; # now $data is an string
95    array_join ' ' $foo;  # now $foo is an string
96}
97```
98
99[Back to TOC](#table-of-contents)
100
101Limitations
102===========
103
104* ngx_form_input will discard request bodies that are buffered
105to disk files. When the client_max_body_size setting is larger than
106client_body_buffer_size, request bodies that are larger
107than client_body_buffer_size (but no larger than
108client_max_body_size) will be buffered to disk files.
109So it's important to ensure these two config settings take
110the same values to avoid confustion.
111
112[Back to TOC](#table-of-contents)
113
114Compatibility
115=============
116
117The following versions of Nginx should work with this module:
118
119* 1.9.x (last tested: 1.9.7)
120* 1.8.x
121* 1.7.x (last tested: 1.7.4)
122* 1.6.x
123* 1.5.x (last tested: 1.5.12)
124* 1.4.x (last tested: 1.4.6)
125* 1.1.x (last tested: 1.1.5)
126* 1.0.x (last tested: 1.0.8)
127* 0.9.x (last tested: 0.9.4)
128* 0.8.x >= 0.8.54
129
130[Back to TOC](#table-of-contents)
131
132Copyright & License
133===================
134
135Copyright (c) 2010, 2011, Jiale "calio" Zhi <vipcalio@gmail.com>.
136
137Copyright (c) 2010-2016, Yichun "agentzh" Zhang <agentzh@gmail.com>, CloudFlare Inc.
138
139This module is licensed under the terms of the BSD license.
140
141Redistribution and use in source and binary forms, with or without
142modification, are permitted provided that the following conditions are
143met:
144
145* Redistributions of source code must retain the above copyright
146notice, this list of conditions and the following disclaimer.
147* Redistributions in binary form must reproduce the above copyright
148notice, this list of conditions and the following disclaimer in the
149documentation and/or other materials provided with the distribution.
150
151THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
152IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
153TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
154PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
155HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
156SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
157TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
158PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
159LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
160NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
161SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
162
163[Back to TOC](#table-of-contents)
164
165