Skip to content

Commit 2ac3aa2

Browse files
committed
updated docs to reflect recent changes.
1 parent c9c5f94 commit 2ac3aa2

File tree

3 files changed

+144
-31
lines changed

3 files changed

+144
-31
lines changed

README

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Status
88
This module is under active development and is production ready.
99

1010
Version
11-
This document describes ngx_lua v0.5.0rc17
12-
(<https://github.com/chaoslawful/lua-nginx-module/tags>) released on 6
11+
This document describes ngx_lua v0.5.0rc19
12+
(<https://github.com/chaoslawful/lua-nginx-module/tags>) released on 15
1313
March 2012.
1414

1515
Synopsis
@@ -845,6 +845,29 @@ Directives
845845

846846
This directive was first introduced in the "v0.5.0rc1" release.
847847

848+
lua_http10_buffering
849+
syntax: *lua_http10_buffering on|off*
850+
851+
default: *lua_http10_buffering on*
852+
853+
context: *http, server, location, location-if*
854+
855+
Enables or disables the automatic response caching for HTTP 1.0 (or
856+
older) requests. This buffering mechanism is mainly used for HTTP 1.0
857+
keep-alive which replies on a proper "Content-Length" response header.
858+
859+
If the Lua code explicitly sets a "Content-Length" response header
860+
before sending the headers (either explicity via ngx.send_headers or
861+
implicitly via the first ngx.say or ngx.print call).
862+
863+
If you want to output huge response data in a streaming fashion (via the
864+
ngx.flush call, for example), then you MUST turn off this directive to
865+
prevent memory footprint boost.
866+
867+
This directive is turned "on" by default.
868+
869+
THis directive was first introduced in the "v0.5.0rc19" release.
870+
848871
Nginx API for Lua
849872
Introduction
850873
The various *_by_lua and *_by_lua_file configuration directives serve as
@@ -960,9 +983,11 @@ Nginx API for Lua
960983
ngx.ERROR (-1)
961984
ngx.AGAIN (-2)
962985
ngx.DONE (-4)
986+
ngx.DECLINED (-5)
963987

964-
Note that only two of these constants are utilized by the Nginx API for
965-
Lua (i.e., ngx.exit accepts "NGX_OK" and "NGX_ERROR" as input).
988+
Note that only three of these constants are utilized by the Nginx API
989+
for Lua (i.e., ngx.exit accepts "NGX_OK", "NGX_ERROR", and
990+
"NGX_DECLINED" as input).
966991

967992
ngx.null
968993

@@ -972,6 +997,9 @@ Nginx API for Lua
972997
library's "cjson.null" constant. This constant was first introduced in
973998
the "v0.5.0rc5" release.
974999

1000+
The "ngx.DECLINED" constant was first introduced in the "v0.5.0rc19"
1001+
release.
1002+
9751003
HTTP method constants
9761004
context: *set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*,
9771005
header_filter_by_lua**
@@ -1677,6 +1705,12 @@ Nginx API for Lua
16771705
where in the latter case, this method will automatically escape argument
16781706
keys and values according to the URI escaping rule.
16791707

1708+
Multi-value arguments are also supported:
1709+
1710+
ngx.req.set_uri_args({ a = 3, b = {5, 6} })
1711+
1712+
which will result in a querystring like "a=3&b=5&b=6".
1713+
16801714
This interface was first introduced in the "v0.3.1rc13" release.
16811715

16821716
See also ngx.req.set_uri.
@@ -3722,13 +3756,23 @@ Nginx API for Lua
37223756
HTTP 1.0 support
37233757
The HTTP 1.0 protocol does not support chunked outputs and always
37243758
requires an explicit "Content-Length" header when the response body is
3725-
non-empty. So when an HTTP 1.0 request is present, This module will
3759+
non-empty in order to support the HTTP 1.0 keep-alive (as required by
3760+
the ApacheBench (ab) tool). So when an HTTP 1.0 request is present and
3761+
the lua_http10_buffering directive is turned "on", this module will
37263762
automatically buffer all the outputs of user calls of ngx.say and
37273763
ngx.print and postpone sending response headers until it sees all the
37283764
outputs in the response body, and at that time ngx_lua can calculate the
37293765
total length of the body and construct a proper "Content-Length" header
37303766
for the HTTP 1.0 client.
37313767

3768+
If the user Lua code sets the "Content-Length" response header itself,
3769+
then the automatic buffering will be disabled even if the
3770+
lua_http10_buffering directive is turned "on".
3771+
3772+
For big responses' streaming outputs, it's important to disable the
3773+
lua_http10_buffering directive, otherwise the memory usage will grow
3774+
very quickly.
3775+
37323776
Note that, common HTTP benchmark tools like "ab" and "http_load" always
37333777
issue HTTP 1.0 requests by default. To force "curl" to send HTTP 1.0
37343778
requests, use the -0 option.
@@ -4095,14 +4139,19 @@ Bugs and Patches
40954139

40964140
TODO
40974141
Short Term
4098-
* implement the "ngx.sleep(time)" Lua API.
4142+
* implement the "ngx.sleep(time)" Lua API. (For now, use
4143+
ngx.location.capture with [[HttpEchoModule]]'s echo_sleep config
4144+
directive instead.)
40994145

4100-
* implement the "ngx.worker.get_pid()" Lua API.
4146+
* implement the "ngx.worker.get_pid()" Lua API. (For now, use
4147+
"ngx.var.pid" directly.)
41014148

41024149
* implement LuaSocket UDP API
41034150
(<http://w3.impa.br/~diego/software/luasocket/udp.html>) in our
41044151
cosocket API.
41054152

4153+
* implement the SSL cosocket API.
4154+
41064155
* implement the "ngx.re.split" method.
41074156

41084157
* use "ngx_hash_t" to optimize the built-in header look-up process for
@@ -4120,9 +4169,6 @@ TODO
41204169

41214170
* deal with TCP 3-second delay problem under great connection harness.
41224171

4123-
* add support for multi-value arguments to ngx.req.set_uri_args if its
4124-
"args" argument is a Lua table.
4125-
41264172
* add APIs to access cookies as key/value pairs.
41274173

41284174
* add "ignore_resp_headers", "ignore_resp_body", and "ignore_resp"
@@ -4553,5 +4599,6 @@ See Also
45534599

45544600
* The ngx_openresty bundle (<http://openresty.org>)
45554601

4556-
* [Chinese (HttpLuaModuleZh)]
4602+
Translations
4603+
* Chinese
45574604

README.markdown

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This module is under active development and is production ready.
1313
Version
1414
=======
1515

16-
This document describes ngx_lua [v0.5.0rc17](https://github.com/chaoslawful/lua-nginx-module/tags) released on 6 March 2012.
16+
This document describes ngx_lua [v0.5.0rc19](https://github.com/chaoslawful/lua-nginx-module/tags) released on 15 March 2012.
1717

1818
Synopsis
1919
========
@@ -786,6 +786,25 @@ The `<time>` argument can be an integer, with an optional time unit, like `s` (s
786786

787787
This directive was first introduced in the `v0.5.0rc1` release.
788788

789+
lua_http10_buffering
790+
--------------------
791+
792+
**syntax:** *lua_http10_buffering on|off*
793+
794+
**default:** *lua_http10_buffering on*
795+
796+
**context:** *http, server, location, location-if*
797+
798+
Enables or disables the automatic response caching for HTTP 1.0 (or older) requests. This buffering mechanism is mainly used for HTTP 1.0 keep-alive which replies on a proper `Content-Length` response header.
799+
800+
If the Lua code explicitly sets a `Content-Length` response header before sending the headers (either explicity via [ngx.send_headers](http://wiki.nginx.org/HttpLuaModule#ngx.send_headers) or implicitly via the first [ngx.say](http://wiki.nginx.org/HttpLuaModule#ngx.say) or [ngx.print](http://wiki.nginx.org/HttpLuaModule#ngx.print) call).
801+
802+
If you want to output huge response data in a streaming fashion (via the [ngx.flush](http://wiki.nginx.org/HttpLuaModule#ngx.flush) call, for example), then you MUST turn off this directive to prevent memory footprint boost.
803+
804+
This directive is turned `on` by default.
805+
806+
THis directive was first introduced in the `v0.5.0rc19` release.
807+
789808
Nginx API for Lua
790809
=================
791810
Introduction
@@ -900,16 +919,19 @@ Core constants
900919
ngx.ERROR (-1)
901920
ngx.AGAIN (-2)
902921
ngx.DONE (-4)
922+
ngx.DECLINED (-5)
903923

904924

905-
Note that only two of these constants are utilized by the [Nginx API for Lua](http://wiki.nginx.org/HttpLuaModule#Nginx_API_for_Lua) (i.e., [ngx.exit](http://wiki.nginx.org/HttpLuaModule#ngx.exit) accepts `NGX_OK` and `NGX_ERROR` as input).
925+
Note that only three of these constants are utilized by the [Nginx API for Lua](http://wiki.nginx.org/HttpLuaModule#Nginx_API_for_Lua) (i.e., [ngx.exit](http://wiki.nginx.org/HttpLuaModule#ngx.exit) accepts `NGX_OK`, `NGX_ERROR`, and `NGX_DECLINED` as input).
906926

907927

908928
ngx.null
909929

910930

911931
The `ngx.null` constant is a `NULL` light userdata which is usually used to represent nil values in Lua tables and etc. It is identical with the [lua-cjson](http://www.kyne.com.au/~mark/software/lua-cjson.php) library's `cjson.null` constant. This constant was first introduced in the `v0.5.0rc5` release.
912932

933+
The `ngx.DECLINED` constant was first introduced in the `v0.5.0rc19` release.
934+
913935
HTTP method constants
914936
---------------------
915937
**context:** *set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua**
@@ -1623,6 +1645,14 @@ or a Lua table holding the query arguments' key-value pairs, as in
16231645

16241646
where in the latter case, this method will automatically escape argument keys and values according to the URI escaping rule.
16251647

1648+
Multi-value arguments are also supported:
1649+
1650+
1651+
ngx.req.set_uri_args({ a = 3, b = {5, 6} })
1652+
1653+
1654+
which will result in a querystring like `a=3&b=5&b=6`.
1655+
16261656
This interface was first introduced in the `v0.3.1rc13` release.
16271657

16281658
See also [ngx.req.set_uri](http://wiki.nginx.org/HttpLuaModule#ngx.req.set_uri).
@@ -3425,13 +3455,17 @@ HTTP 1.0 support
34253455
================
34263456

34273457
The HTTP 1.0 protocol does not support chunked outputs and always requires an
3428-
explicit `Content-Length` header when the response body is non-empty. So when
3429-
an HTTP 1.0 request is present, This module will automatically buffer all the
3458+
explicit `Content-Length` header when the response body is non-empty in order to support the HTTP 1.0 keep-alive (as required by the ApacheBench (ab) tool). So when
3459+
an HTTP 1.0 request is present and the [lua_http10_buffering](http://wiki.nginx.org/HttpLuaModule#lua_http10_buffering) directive is turned `on`, this module will automatically buffer all the
34303460
outputs of user calls of [ngx.say](http://wiki.nginx.org/HttpLuaModule#ngx.say) and [ngx.print](http://wiki.nginx.org/HttpLuaModule#ngx.print) and
34313461
postpone sending response headers until it sees all the outputs in the response
34323462
body, and at that time ngx_lua can calculate the total length of the body and
34333463
construct a proper `Content-Length` header for the HTTP 1.0 client.
34343464

3465+
If the user Lua code sets the `Content-Length` response header itself, then the automatic buffering will be disabled even if the [lua_http10_buffering](http://wiki.nginx.org/HttpLuaModule#lua_http10_buffering) directive is turned `on`.
3466+
3467+
For big responses' streaming outputs, it's important to disable the [lua_http10_buffering](http://wiki.nginx.org/HttpLuaModule#lua_http10_buffering) directive, otherwise the memory usage will grow very quickly.
3468+
34353469
Note that, common HTTP benchmark tools like `ab` and `http_load` always issue
34363470
HTTP 1.0 requests by default. To force `curl` to send HTTP 1.0 requests, use
34373471
the `-0` option.
@@ -3718,16 +3752,16 @@ TODO
37183752

37193753
Short Term
37203754
----------
3721-
* implement the `ngx.sleep(time)` Lua API.
3722-
* implement the `ngx.worker.get_pid()` Lua API.
3755+
* implement the `ngx.sleep(time)` Lua API. (For now, use [ngx.location.capture](http://wiki.nginx.org/HttpLuaModule#ngx.location.capture) with [HttpEchoModule](http://wiki.nginx.org/HttpEchoModule)'s [echo_sleep](http://wiki.nginx.org/HttpEchoModule#echo_sleep) config directive instead.)
3756+
* implement the `ngx.worker.get_pid()` Lua API. (For now, use `ngx.var.pid` directly.)
37233757
* implement [LuaSocket UDP API](http://w3.impa.br/~diego/software/luasocket/udp.html) in our cosocket API.
3758+
* implement the SSL cosocket API.
37243759
* implement the `ngx.re.split` method.
37253760
* use `ngx_hash_t` to optimize the built-in header look-up process for [ngx.req.set_header](http://wiki.nginx.org/HttpLuaModule#ngx.req.set_header), [ngx.header.HEADER](http://wiki.nginx.org/HttpLuaModule#ngx.header.HEADER), and etc.
37263761
* fix HTTP 1.0 support: we should by default close the current HTTP 1.0 connection right away if no `Content-Length` response header is set. the current automatic full buffering bahvior is way too expensive.
37273762
* add configure options for different strategies of handling the cosocket connection exceeding in the pools.
37283763
* add directives to run Lua codes when nginx stops/reloads.
37293764
* deal with TCP 3-second delay problem under great connection harness.
3730-
* add support for multi-value arguments to [ngx.req.set_uri_args](http://wiki.nginx.org/HttpLuaModule#ngx.req.set_uri_args) if its `args` argument is a Lua table.
37313765
* add APIs to access cookies as key/value pairs.
37323766
* add `ignore_resp_headers`, `ignore_resp_body`, and `ignore_resp` options to [ngx.location.capture](http://wiki.nginx.org/HttpLuaModule#ngx.location.capture) and [ngx.location.capture_multi](http://wiki.nginx.org/HttpLuaModule#ngx.location.capture_multi) methods, to allow micro performance tuning on the user side.
37333767

@@ -3916,7 +3950,7 @@ See Also
39163950
* [HttpMemcModule](http://wiki.nginx.org/HttpMemcModule)
39173951
* [The ngx_openresty bundle](http://openresty.org)
39183952

3919-
<div id="translations">
3920-
* [ Chinese](http://wiki.nginx.org/HttpLuaModuleZh)
3921-
</div>
3953+
Translations
3954+
============
3955+
* [Chinese](http://wiki.nginx.org/HttpLuaModuleZh)
39223956

doc/HttpLuaModule.wiki

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This module is under active development and is production ready.
1010

1111
= Version =
1212

13-
This document describes ngx_lua [https://github.com/chaoslawful/lua-nginx-module/tags v0.5.0rc17] released on 6 March 2012.
13+
This document describes ngx_lua [https://github.com/chaoslawful/lua-nginx-module/tags v0.5.0rc19] released on 15 March 2012.
1414

1515
= Synopsis =
1616
<geshi lang="nginx">
@@ -757,6 +757,24 @@ The <code><time></code> argument can be an integer, with an optional time unit,
757757
758758
This directive was first introduced in the <code>v0.5.0rc1</code> release.
759759
760+
== lua_http10_buffering ==
761+
762+
'''syntax:''' ''lua_http10_buffering on|off''
763+
764+
'''default:''' ''lua_http10_buffering on''
765+
766+
'''context:''' ''http, server, location, location-if''
767+
768+
Enables or disables the automatic response caching for HTTP 1.0 (or older) requests. This buffering mechanism is mainly used for HTTP 1.0 keep-alive which replies on a proper <code>Content-Length</code> response header.
769+
770+
If the Lua code explicitly sets a <code>Content-Length</code> response header before sending the headers (either explicity via [[#ngx.send_headers|ngx.send_headers]] or implicitly via the first [[#ngx.say|ngx.say]] or [[#ngx.print|ngx.print]] call).
771+
772+
If you want to output huge response data in a streaming fashion (via the [[#ngx.flush|ngx.flush]] call, for example), then you MUST turn off this directive to prevent memory footprint boost.
773+
774+
This directive is turned <code>on</code> by default.
775+
776+
THis directive was first introduced in the <code>v0.5.0rc19</code> release.
777+
760778
= Nginx API for Lua =
761779
== Introduction ==
762780
The various <code>*_by_lua</code> and <code>*_by_lua_file</code> configuration directives serve as gateways to the Lua API within the <code>nginx.conf</code> file. The Nginx Lua API described below can only be called within the user Lua code run in the context of these configuration directives.
@@ -866,16 +884,19 @@ Setting <code>ngx.var.Foo</code> to a <code>nil</code> value will unset the <cod
866884
ngx.ERROR (-1)
867885
ngx.AGAIN (-2)
868886
ngx.DONE (-4)
887+
ngx.DECLINED (-5)
869888
</geshi>
870889
871-
Note that only two of these constants are utilized by the [[#Nginx API for Lua|Nginx API for Lua]] (i.e., [[#ngx.exit|ngx.exit]] accepts <code>NGX_OK</code> and <code>NGX_ERROR</code> as input).
890+
Note that only three of these constants are utilized by the [[#Nginx API for Lua|Nginx API for Lua]] (i.e., [[#ngx.exit|ngx.exit]] accepts <code>NGX_OK</code>, <code>NGX_ERROR</code>, and <code>NGX_DECLINED</code> as input).
872891
873892
<geshi lang="lua">
874893
ngx.null
875894
</geshi>
876895
877896
The <code>ngx.null</code> constant is a <code>NULL</code> light userdata which is usually used to represent nil values in Lua tables and etc. It is identical with the [http://www.kyne.com.au/~mark/software/lua-cjson.php lua-cjson] library's <code>cjson.null</code> constant. This constant was first introduced in the <code>v0.5.0rc5</code> release.
878897
898+
The <code>ngx.DECLINED</code> constant was first introduced in the <code>v0.5.0rc19</code> release.
899+
879900
== HTTP method constants ==
880901
'''context:''' ''set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*''
881902
@@ -1578,6 +1599,14 @@ or a Lua table holding the query arguments' key-value pairs, as in
15781599
15791600
where in the latter case, this method will automatically escape argument keys and values according to the URI escaping rule.
15801601
1602+
Multi-value arguments are also supported:
1603+
1604+
<geshi lang="lua">
1605+
ngx.req.set_uri_args({ a = 3, b = {5, 6} })
1606+
</geshi>
1607+
1608+
which will result in a querystring like <code>a=3&b=5&b=6</code>.
1609+
15811610
This interface was first introduced in the <code>v0.3.1rc13</code> release.
15821611
15831612
See also [[#ngx.req.set_uri|ngx.req.set_uri]].
@@ -3312,13 +3341,17 @@ This feature requires the [https://github.com/simpl/ngx_devel_kit ngx_devel_kit]
33123341
= HTTP 1.0 support =
33133342
33143343
The HTTP 1.0 protocol does not support chunked outputs and always requires an
3315-
explicit <code>Content-Length</code> header when the response body is non-empty. So when
3316-
an HTTP 1.0 request is present, This module will automatically buffer all the
3344+
explicit <code>Content-Length</code> header when the response body is non-empty in order to support the HTTP 1.0 keep-alive (as required by the ApacheBench (ab) tool). So when
3345+
an HTTP 1.0 request is present and the [[#lua_http10_buffering|lua_http10_buffering]] directive is turned <code>on</code>, this module will automatically buffer all the
33173346
outputs of user calls of [[#ngx.say|ngx.say]] and [[#ngx.print|ngx.print]] and
33183347
postpone sending response headers until it sees all the outputs in the response
33193348
body, and at that time ngx_lua can calculate the total length of the body and
33203349
construct a proper <code>Content-Length</code> header for the HTTP 1.0 client.
33213350
3351+
If the user Lua code sets the <code>Content-Length</code> response header itself, then the automatic buffering will be disabled even if the [[#lua_http10_buffering|lua_http10_buffering]] directive is turned <code>on</code>.
3352+
3353+
For big responses' streaming outputs, it's important to disable the [[#lua_http10_buffering|lua_http10_buffering]] directive, otherwise the memory usage will grow very quickly.
3354+
33223355
Note that, common HTTP benchmark tools like <code>ab</code> and <code>http_load</code> always issue
33233356
HTTP 1.0 requests by default. To force <code>curl</code> to send HTTP 1.0 requests, use
33243357
the <code>-0</code> option.
@@ -3592,16 +3625,16 @@ Please report bugs or submit patches by:
35923625
= TODO =
35933626
35943627
== Short Term ==
3595-
* implement the <code>ngx.sleep(time)</code> Lua API.
3596-
* implement the <code>ngx.worker.get_pid()</code> Lua API.
3628+
* implement the <code>ngx.sleep(time)</code> Lua API. (For now, use [[#ngx.location.capture|ngx.location.capture]] with [[HttpEchoModule]]'s [[HttpEchoModule#echo_sleep|echo_sleep]] config directive instead.)
3629+
* implement the <code>ngx.worker.get_pid()</code> Lua API. (For now, use <code>ngx.var.pid</code> directly.)
35973630
* implement [http://w3.impa.br/~diego/software/luasocket/udp.html LuaSocket UDP API] in our cosocket API.
3631+
* implement the SSL cosocket API.
35983632
* implement the <code>ngx.re.split</code> method.
35993633
* use <code>ngx_hash_t</code> to optimize the built-in header look-up process for [[#ngx.req.set_header|ngx.req.set_header]], [[#ngx.header.HEADER|ngx.header.HEADER]], and etc.
36003634
* fix HTTP 1.0 support: we should by default close the current HTTP 1.0 connection right away if no <code>Content-Length</code> response header is set. the current automatic full buffering bahvior is way too expensive.
36013635
* add configure options for different strategies of handling the cosocket connection exceeding in the pools.
36023636
* add directives to run Lua codes when nginx stops/reloads.
36033637
* deal with TCP 3-second delay problem under great connection harness.
3604-
* add support for multi-value arguments to [[#ngx.req.set_uri_args|ngx.req.set_uri_args]] if its <code>args</code> argument is a Lua table.
36053638
* add APIs to access cookies as key/value pairs.
36063639
* add <code>ignore_resp_headers</code>, <code>ignore_resp_body</code>, and <code>ignore_resp</code> options to [[#ngx.location.capture|ngx.location.capture]] and [[#ngx.location.capture_multi|ngx.location.capture_multi]] methods, to allow micro performance tuning on the user side.
36073640
@@ -3782,7 +3815,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
37823815
* [[HttpMemcModule]]
37833816
* [http://openresty.org The ngx_openresty bundle]
37843817
3785-
<div id="translations">
3786-
* [[HttpLuaModuleZh| Chinese]]
3787-
</div>
3818+
= Translations =
3819+
* [[HttpLuaModuleZh|Chinese]]
37883820

0 commit comments

Comments
 (0)