Skip to content

Commit d8aa2fe

Browse files
committed
updated docs to reflect recent changes.
1 parent ff9580d commit d8aa2fe

File tree

3 files changed

+79
-32
lines changed

3 files changed

+79
-32
lines changed

README

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

1010
Version
11-
This document describes ngx_lua v0.8.2
12-
(<https://github.com/chaoslawful/lua-nginx-module/tags>) released on 23
13-
May 2013.
11+
This document describes ngx_lua v0.8.3
12+
(<https://github.com/chaoslawful/lua-nginx-module/tags>) released on 20
13+
June 2013.
1414

1515
Synopsis
1616
# set search paths for pure Lua external libraries (';;' is the default path):
@@ -257,6 +257,12 @@ Directives
257257
to to reload the config file are to send a "HUP" signal or to restart
258258
Nginx.
259259

260+
Also, Lua files which are loaded by "dofile" or "loadfile" in
261+
*_by_lua_file will never be cached. To ensure code caching, you can
262+
either use the init_by_lua or init_by_lua_file directives to load all
263+
such files or just make these Lua files true Lua modules and load them
264+
via "require".
265+
260266
The ngx_lua module does not currently support the "stat" mode available
261267
with the Apache "mod_lua" module but this is planned for implementation
262268
in the future.
@@ -2741,7 +2747,7 @@ Nginx API for Lua
27412747
to the same size value in client_max_body_size.
27422748

27432749
Note that calling this function instead of using "ngx.var.request_body"
2744-
or "ngx.var.echo_request-body" is more efficient because it can save one
2750+
or "ngx.var.echo_request_body" is more efficient because it can save one
27452751
dynamic memory allocation and one data copy.
27462752

27472753
This function was first introduced in the "v0.3.1rc17" release.
@@ -3036,12 +3042,15 @@ Nginx API for Lua
30363042
call, i.e., "return ngx.redirect(...)", so as to be more explicit.
30373043

30383044
ngx.send_headers
3039-
syntax: *ngx.send_headers()*
3045+
syntax: *ok, err = ngx.send_headers()*
30403046

30413047
context: *rewrite_by_lua*, access_by_lua*, content_by_lua**
30423048

30433049
Explicitly send out the response headers.
30443050

3051+
Since "v0.8.3" this function returns 1 on success, or returns "nil" and
3052+
a string describing the error otherwise.
3053+
30453054
Note that there is normally no need to manually send out response
30463055
headers as ngx_lua will automatically send headers out before content is
30473056
output with ngx.say or ngx.print or when content_by_lua exits normally.
@@ -3057,14 +3066,17 @@ Nginx API for Lua
30573066
This API was first introduced in ngx_lua v0.3.1rc6.
30583067

30593068
ngx.print
3060-
syntax: *ngx.print(...)*
3069+
syntax: *ok, err = ngx.print(...)*
30613070

30623071
context: *rewrite_by_lua*, access_by_lua*, content_by_lua**
30633072

30643073
Emits arguments concatenated to the HTTP client (as response body). If
30653074
response headers have not been sent, this function will send headers out
30663075
first and then output body data.
30673076

3077+
Since "v0.8.3" this function returns 1 on success, or returns "nil" and
3078+
a string describing the error otherwise.
3079+
30683080
Lua "nil" values will output "nil" strings and Lua boolean values will
30693081
output "true" and "false" literal strings respectively.
30703082

@@ -3098,7 +3110,7 @@ Nginx API for Lua
30983110
the data yourself in Lua and save the calls.
30993111

31003112
ngx.say
3101-
syntax: *ngx.say(...)*
3113+
syntax: *ok, err = ngx.say(...)*
31023114

31033115
context: *rewrite_by_lua*, access_by_lua*, content_by_lua**
31043116

@@ -3128,7 +3140,7 @@ Nginx API for Lua
31283140
file in the Nginx source tree.
31293141

31303142
ngx.flush
3131-
syntax: *ngx.flush(wait?)*
3143+
syntax: *ok, err = ngx.flush(wait?)*
31323144

31333145
context: *rewrite_by_lua*, access_by_lua*, content_by_lua**
31343146

@@ -3154,6 +3166,9 @@ Nginx API for Lua
31543166
Note that "ngx.flush" is non functional when in the HTTP 1.0 output
31553167
buffering mode. See HTTP 1.0 support.
31563168

3169+
Since "v0.8.3" this function returns 1 on success, or returns "nil" and
3170+
a string describing the error otherwise.
3171+
31573172
ngx.exit
31583173
syntax: *ngx.exit(status)*
31593174

@@ -3202,7 +3217,7 @@ Nginx API for Lua
32023217
hint to others reading the code.
32033218

32043219
ngx.eof
3205-
syntax: *ngx.eof()*
3220+
syntax: *ok, err = ngx.eof()*
32063221

32073222
context: *rewrite_by_lua*, access_by_lua*, content_by_lua**
32083223

@@ -3235,6 +3250,9 @@ Nginx API for Lua
32353250

32363251
proxy_ignore_client_abort on;
32373252

3253+
Since "v0.8.3" this function returns 1 on success, or returns "nil" and
3254+
a string describing the error otherwise.
3255+
32383256
ngx.sleep
32393257
syntax: *ngx.sleep(seconds)*
32403258

@@ -5854,6 +5872,8 @@ Typical Uses
58545872
Nginx Compatibility
58555873
The latest module is compatible with the following versions of Nginx:
58565874

5875+
* 1.4.x (last tested: 1.4.1)
5876+
58575877
* 1.3.x (last tested: 1.3.11)
58585878

58595879
* 1.2.x (last tested: 1.2.9)
@@ -5897,9 +5917,9 @@ Installation
58975917

58985918
Build the source with this module:
58995919

5900-
wget 'http://nginx.org/download/nginx-1.2.9.tar.gz'
5901-
tar -xzvf nginx-1.2.9.tar.gz
5902-
cd nginx-1.2.9/
5920+
wget 'http://nginx.org/download/nginx-1.4.1.tar.gz'
5921+
tar -xzvf nginx-1.4.1.tar.gz
5922+
cd nginx-1.4.1/
59035923

59045924
# tell nginx's build system where to find LuaJIT:
59055925
export LUAJIT_LIB=/path/to/luajit/lib

README.markdown

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This module is under active development and is production ready.
1818
Version
1919
=======
2020

21-
This document describes ngx_lua [v0.8.2](https://github.com/chaoslawful/lua-nginx-module/tags) released on 23 May 2013.
21+
This document describes ngx_lua [v0.8.3](https://github.com/chaoslawful/lua-nginx-module/tags) released on 20 June 2013.
2222

2323
Synopsis
2424
========
@@ -247,6 +247,10 @@ cached because only the Nginx config file parser can correctly parse the `nginx.
247247
file and the only ways to to reload the config file
248248
are to send a `HUP` signal or to restart Nginx.
249249

250+
Also, Lua files which are loaded by `dofile` or `loadfile`
251+
in *_by_lua_file will never be cached. To ensure code caching, you can either use the [init_by_lua](http://wiki.nginx.org/HttpLuaModule#init_by_lua)
252+
or [init_by_lua_file](http://wiki.nginx.org/HttpLuaModule#init-by_lua_file) directives to load all such files or just make these Lua files true Lua modules and load them via `require`.
253+
250254
The ngx_lua module does not currently support the `stat` mode available with the
251255
Apache `mod_lua` module but this is planned for implementation in the future.
252256

@@ -2559,7 +2563,7 @@ If the request body has been read into disk files, try calling the [ngx.req.get_
25592563

25602564
To force in-memory request bodies, try setting [client_body_buffer_size](http://wiki.nginx.org/HttpCoreModule#client_body_buffer_size) to the same size value in [client_max_body_size](http://wiki.nginx.org/HttpCoreModule#client_max_body_size).
25612565

2562-
Note that calling this function instead of using `ngx.var.request_body` or `ngx.var.echo_request-body` is more efficient because it can save one dynamic memory allocation and one data copy.
2566+
Note that calling this function instead of using `ngx.var.request_body` or `ngx.var.echo_request_body` is more efficient because it can save one dynamic memory allocation and one data copy.
25632567

25642568
This function was first introduced in the `v0.3.1rc17` release.
25652569

@@ -2819,12 +2823,14 @@ This method call terminates the current request's processing and never returns.
28192823

28202824
ngx.send_headers
28212825
----------------
2822-
**syntax:** *ngx.send_headers()*
2826+
**syntax:** *ok, err = ngx.send_headers()*
28232827

28242828
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua**
28252829

28262830
Explicitly send out the response headers.
28272831

2832+
Since `v0.8.3` this function returns `1` on success, or returns `nil` and a string describing the error otherwise.
2833+
28282834
Note that there is normally no need to manually send out response headers as ngx_lua will automatically send headers out
28292835
before content is output with [ngx.say](http://wiki.nginx.org/HttpLuaModule#ngx.say) or [ngx.print](http://wiki.nginx.org/HttpLuaModule#ngx.print) or when [content_by_lua](http://wiki.nginx.org/HttpLuaModule#content_by_lua) exits normally.
28302836

@@ -2840,12 +2846,14 @@ This API was first introduced in ngx_lua v0.3.1rc6.
28402846

28412847
ngx.print
28422848
---------
2843-
**syntax:** *ngx.print(...)*
2849+
**syntax:** *ok, err = ngx.print(...)*
28442850

28452851
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua**
28462852

28472853
Emits arguments concatenated to the HTTP client (as response body). If response headers have not been sent, this function will send headers out first and then output body data.
28482854

2855+
Since `v0.8.3` this function returns `1` on success, or returns `nil` and a string describing the error otherwise.
2856+
28492857
Lua `nil` values will output `"nil"` strings and Lua boolean values will output `"true"` and `"false"` literal strings respectively.
28502858

28512859
Nested arrays of strings are permitted and the elements in the arrays will be sent one by one:
@@ -2875,7 +2883,7 @@ Please note that both `ngx.print` and [ngx.say](http://wiki.nginx.org/HttpLuaMod
28752883

28762884
ngx.say
28772885
-------
2878-
**syntax:** *ngx.say(...)*
2886+
**syntax:** *ok, err = ngx.say(...)*
28792887

28802888
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua**
28812889

@@ -2897,7 +2905,7 @@ There is a hard coded `2048` byte limitation on error message lengths in the Ngi
28972905

28982906
ngx.flush
28992907
---------
2900-
**syntax:** *ngx.flush(wait?)*
2908+
**syntax:** *ok, err = ngx.flush(wait?)*
29012909

29022910
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua**
29032911

@@ -2911,6 +2919,8 @@ When `ngx.flush(true)` is called immediately after [ngx.print](http://wiki.nginx
29112919

29122920
Note that `ngx.flush` is non functional when in the HTTP 1.0 output buffering mode. See [HTTP 1.0 support](http://wiki.nginx.org/HttpLuaModule#HTTP_1.0_support).
29132921

2922+
Since `v0.8.3` this function returns `1` on success, or returns `nil` and a string describing the error otherwise.
2923+
29142924
ngx.exit
29152925
--------
29162926
**syntax:** *ngx.exit(status)*
@@ -2959,7 +2969,7 @@ It is recommended, though not necessary, to combine the `return` statement with
29592969

29602970
ngx.eof
29612971
-------
2962-
**syntax:** *ngx.eof()*
2972+
**syntax:** *ok, err = ngx.eof()*
29632973

29642974
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua**
29652975

@@ -2984,6 +2994,8 @@ But if you create subrequests to access other locations configured by Nginx upst
29842994
proxy_ignore_client_abort on;
29852995

29862996

2997+
Since `v0.8.3` this function returns `1` on success, or returns `nil` and a string describing the error otherwise.
2998+
29872999
ngx.sleep
29883000
---------
29893001
**syntax:** *ngx.sleep(seconds)*
@@ -5207,6 +5219,7 @@ Nginx Compatibility
52075219
===================
52085220
The latest module is compatible with the following versions of Nginx:
52095221

5222+
* 1.4.x (last tested: 1.4.1)
52105223
* 1.3.x (last tested: 1.3.11)
52115224
* 1.2.x (last tested: 1.2.9)
52125225
* 1.1.x (last tested: 1.1.5)
@@ -5234,9 +5247,9 @@ Alternatively, ngx_lua can be manually compiled into Nginx:
52345247
Build the source with this module:
52355248

52365249

5237-
wget 'http://nginx.org/download/nginx-1.2.9.tar.gz'
5238-
tar -xzvf nginx-1.2.9.tar.gz
5239-
cd nginx-1.2.9/
5250+
wget 'http://nginx.org/download/nginx-1.4.1.tar.gz'
5251+
tar -xzvf nginx-1.4.1.tar.gz
5252+
cd nginx-1.4.1/
52405253

52415254
# tell nginx's build system where to find LuaJIT:
52425255
export LUAJIT_LIB=/path/to/luajit/lib

doc/HttpLuaModule.wiki

Lines changed: 24 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.8.2] released on 23 May 2013.
13+
This document describes ngx_lua [https://github.com/chaoslawful/lua-nginx-module/tags v0.8.3] released on 20 June 2013.
1414

1515
= Synopsis =
1616
<geshi lang="nginx">
@@ -235,6 +235,11 @@ cached because only the Nginx config file parser can correctly parse the <code>n
235235
file and the only ways to to reload the config file
236236
are to send a <code>HUP</code> signal or to restart Nginx.
237237

238+
Also, Lua files which are loaded by <code>dofile</code> or <code>loadfile</code>
239+
in *_by_lua_file will never be cached. To ensure code caching, you can either use the [[#init_by_lua|init_by_lua]]
240+
or [[#init-by_lua_file|init_by_lua_file]] directives to load all such files or just make these Lua files true Lua modules
241+
and load them via <code>require</code>.
242+
238243
The ngx_lua module does not currently support the <code>stat</code> mode available with the
239244
Apache <code>mod_lua</code> module but this is planned for implementation in the future.
240245

@@ -2483,7 +2488,7 @@ If the request body has been read into disk files, try calling the [[#ngx.req.ge
24832488
24842489
To force in-memory request bodies, try setting [[HttpCoreModule#client_body_buffer_size|client_body_buffer_size]] to the same size value in [[HttpCoreModule#client_max_body_size|client_max_body_size]].
24852490
2486-
Note that calling this function instead of using <code>ngx.var.request_body</code> or <code>ngx.var.echo_request-body</code> is more efficient because it can save one dynamic memory allocation and one data copy.
2491+
Note that calling this function instead of using <code>ngx.var.request_body</code> or <code>ngx.var.echo_request_body</code> is more efficient because it can save one dynamic memory allocation and one data copy.
24872492
24882493
This function was first introduced in the <code>v0.3.1rc17</code> release.
24892494
@@ -2733,12 +2738,14 @@ URI arguments can be specified as well, for example:
27332738
This method call terminates the current request's processing and never returns. It is recommended to combine the <code>return</code> statement with this call, i.e., <code>return ngx.redirect(...)</code>, so as to be more explicit.
27342739
27352740
== ngx.send_headers ==
2736-
'''syntax:''' ''ngx.send_headers()''
2741+
'''syntax:''' ''ok, err = ngx.send_headers()''
27372742
27382743
'''context:''' ''rewrite_by_lua*, access_by_lua*, content_by_lua*''
27392744
27402745
Explicitly send out the response headers.
27412746
2747+
Since <code>v0.8.3</code> this function returns <code>1</code> on success, or returns <code>nil</code> and a string describing the error otherwise.
2748+
27422749
Note that there is normally no need to manually send out response headers as ngx_lua will automatically send headers out
27432750
before content is output with [[#ngx.say|ngx.say]] or [[#ngx.print|ngx.print]] or when [[#content_by_lua|content_by_lua]] exits normally.
27442751
@@ -2752,12 +2759,14 @@ Returns <code>true</code> if the response headers have been sent (by ngx_lua), a
27522759
This API was first introduced in ngx_lua v0.3.1rc6.
27532760
27542761
== ngx.print ==
2755-
'''syntax:''' ''ngx.print(...)''
2762+
'''syntax:''' ''ok, err = ngx.print(...)''
27562763
27572764
'''context:''' ''rewrite_by_lua*, access_by_lua*, content_by_lua*''
27582765
27592766
Emits arguments concatenated to the HTTP client (as response body). If response headers have not been sent, this function will send headers out first and then output body data.
27602767
2768+
Since <code>v0.8.3</code> this function returns <code>1</code> on success, or returns <code>nil</code> and a string describing the error otherwise.
2769+
27612770
Lua <code>nil</code> values will output <code>"nil"</code> strings and Lua boolean values will output <code>"true"</code> and <code>"false"</code> literal strings respectively.
27622771
27632772
Nested arrays of strings are permitted and the elements in the arrays will be sent one by one:
@@ -2786,7 +2795,7 @@ This is an asynchronous call and will return immediately without waiting for all
27862795
Please note that both <code>ngx.print</code> and [[#ngx.say|ngx.say]] will always invoke the whole Nginx output body filter chain, which is an expensive operation. So be careful when calling either of these two in a tight loop; buffer the data yourself in Lua and save the calls.
27872796
27882797
== ngx.say ==
2789-
'''syntax:''' ''ngx.say(...)''
2798+
'''syntax:''' ''ok, err = ngx.say(...)''
27902799
27912800
'''context:''' ''rewrite_by_lua*, access_by_lua*, content_by_lua*''
27922801
@@ -2806,7 +2815,7 @@ The <code>log_level</code> argument can take constants like <code>ngx.ERR</code>
28062815
There is a hard coded <code>2048</code> byte limitation on error message lengths in the Nginx core. This limit includes trailing newlines and leading time stamps. If the message size exceeds this limit, Nginx will truncate the message text accordingly. This limit can be manually modified by editing the <code>NGX_MAX_ERROR_STR</code> macro definition in the <code>src/core/ngx_log.h</code> file in the Nginx source tree.
28072816
28082817
== ngx.flush ==
2809-
'''syntax:''' ''ngx.flush(wait?)''
2818+
'''syntax:''' ''ok, err = ngx.flush(wait?)''
28102819
28112820
'''context:''' ''rewrite_by_lua*, access_by_lua*, content_by_lua*''
28122821
@@ -2820,6 +2829,8 @@ When <code>ngx.flush(true)</code> is called immediately after [[#ngx.print|ngx.p
28202829
28212830
Note that <code>ngx.flush</code> is non functional when in the HTTP 1.0 output buffering mode. See [[#HTTP 1.0 support|HTTP 1.0 support]].
28222831
2832+
Since <code>v0.8.3</code> this function returns <code>1</code> on success, or returns <code>nil</code> and a string describing the error otherwise.
2833+
28232834
== ngx.exit ==
28242835
'''syntax:''' ''ngx.exit(status)''
28252836
@@ -2866,7 +2877,7 @@ Note that while this method accepts all [[#HTTP status constants|HTTP status con
28662877
It is recommended, though not necessary, to combine the <code>return</code> statement with this call, i.e., <code>return ngx.exit(...)</code>, to give a visual hint to others reading the code.
28672878
28682879
== ngx.eof ==
2869-
'''syntax:''' ''ngx.eof()''
2880+
'''syntax:''' ''ok, err = ngx.eof()''
28702881
28712882
'''context:''' ''rewrite_by_lua*, access_by_lua*, content_by_lua*''
28722883
@@ -2891,6 +2902,8 @@ But if you create subrequests to access other locations configured by Nginx upst
28912902
proxy_ignore_client_abort on;
28922903
</geshi>
28932904
2905+
Since <code>v0.8.3</code> this function returns <code>1</code> on success, or returns <code>nil</code> and a string describing the error otherwise.
2906+
28942907
== ngx.sleep ==
28952908
'''syntax:''' ''ngx.sleep(seconds)''
28962909
@@ -5034,6 +5047,7 @@ On a ThinkPad T400 2.80 GHz laptop, the Hello World example readily achieves 28k
50345047
= Nginx Compatibility =
50355048
The latest module is compatible with the following versions of Nginx:
50365049
5050+
* 1.4.x (last tested: 1.4.1)
50375051
* 1.3.x (last tested: 1.3.11)
50385052
* 1.2.x (last tested: 1.2.9)
50395053
* 1.1.x (last tested: 1.1.5)
@@ -5059,9 +5073,9 @@ Alternatively, ngx_lua can be manually compiled into Nginx:
50595073
Build the source with this module:
50605074
50615075
<geshi lang="bash">
5062-
wget 'http://nginx.org/download/nginx-1.2.9.tar.gz'
5063-
tar -xzvf nginx-1.2.9.tar.gz
5064-
cd nginx-1.2.9/
5076+
wget 'http://nginx.org/download/nginx-1.4.1.tar.gz'
5077+
tar -xzvf nginx-1.4.1.tar.gz
5078+
cd nginx-1.4.1/
50655079
50665080
# tell nginx's build system where to find LuaJIT:
50675081
export LUAJIT_LIB=/path/to/luajit/lib

0 commit comments

Comments
 (0)