Skip to content

Commit 5fa6ff1

Browse files
committed
Updated docs.
* added a note on possible uninitialized variables for short-circuited requests. thanks Simon Eskildsen for the patch in openresty#456. * renamed the section "Special PCRE Sequences" to "Special Escaping Sequences".
1 parent e3cda9c commit 5fa6ff1

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

README.markdown

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ Table of Contents
3838
* [Lua Variable Scope](#lua-variable-scope)
3939
* [Locations Configured by Subrequest Directives of Other Modules](#locations-configured-by-subrequest-directives-of-other-modules)
4040
* [Cosockets Not Available Everywhere](#cosockets-not-available-everywhere)
41-
* [Special PCRE Sequences](#special-pcre-sequences)
41+
* [Special Escaping Sequences](#special-escaping-sequences)
4242
* [Mixing with SSI Not Supported](#mixing-with-ssi-not-supported)
4343
* [SPDY Mode Not Fully Supported](#spdy-mode-not-fully-supported)
44+
* [Missing data on short circuited requests](#missing-data-on-short-circuited-requests)
4445
* [TODO](#todo)
4546
* [Changes](#changes)
4647
* [Test Suite](#test-suite)
@@ -747,8 +748,8 @@ There exists a work-around, however, when the original context does *not* need t
747748

748749
[Back to TOC](#table-of-contents)
749750

750-
Special PCRE Sequences
751-
----------------------
751+
Special Escaping Sequences
752+
--------------------------
752753
PCRE sequences such as `\d`, `\s`, or `\w`, require special attention because in string literals, the backslash character, `\`, is stripped out by both the Lua language parser and by the Nginx config file parser before processing. So the following snippet will not work as expected:
753754

754755
```nginx
@@ -853,6 +854,27 @@ Certain Lua APIs provided by ngx_lua do not work in Nginx's SPDY mode yet: [ngx.
853854

854855
[Back to TOC](#table-of-contents)
855856

857+
Missing data on short circuited requests
858+
----------------------------------------
859+
860+
Nginx may terminate a request early with (at least):
861+
862+
* 400 (Bad Request)
863+
* 405 (Not Allowed)
864+
* 408 (Request Timeout)
865+
* 414 (Request URI Too Large)
866+
* 494 (Request Headers Too Large)
867+
* 499 (Client Closed Request)
868+
* 500 (Internal Server Error)
869+
* 501 (Not Implemented)
870+
871+
This means that phases that normally run are skipped, such as the rewrite or
872+
access phase. This also means that later phases that are run regardless, e.g.
873+
[log_by_lua](#log_by_lua), will not have access to information that is normally set in those
874+
phases.
875+
876+
[Back to TOC](#table-of-contents)
877+
856878
TODO
857879
====
858880

@@ -5094,7 +5116,7 @@ The `ctx` table argument combined with the `a` regex modifier can be used to con
50945116

50955117
Note that, the `options` argument is not optional when the `ctx` argument is specified and that the empty Lua string (`""`) must be used as placeholder for `options` if no meaningful regex options are required.
50965118

5097-
This method requires the PCRE library enabled in Nginx. ([Known Issue With Special PCRE Sequences](#special-pcre-sequences)).
5119+
This method requires the PCRE library enabled in Nginx. ([Known Issue With Special Escaping Sequences](#special-escaping-sequences)).
50985120

50995121
To confirm that PCRE JIT is enabled, activate the Nginx debug log by adding the `--with-debug` option to Nginx or ngx_openresty's `./configure` script. Then, enable the "debug" error log level in `error_log` directive. The following message will be generated if PCRE JIT is enabled:
51005122

@@ -5234,7 +5256,7 @@ The optional `options` argument takes exactly the same semantics as the [ngx.re.
52345256

52355257
The current implementation requires that the iterator returned should only be used in a single request. That is, one should *not* assign it to a variable belonging to persistent namespace like a Lua package.
52365258

5237-
This method requires the PCRE library enabled in Nginx. ([Known Issue With Special PCRE Sequences](#special-pcre-sequences)).
5259+
This method requires the PCRE library enabled in Nginx. ([Known Issue With Special Escaping Sequences](#special-escaping-sequences)).
52385260

52395261
This feature was first introduced in the `v0.2.1rc12` release.
52405262

@@ -5300,7 +5322,7 @@ When the `replace` argument is of type "function", then it will be invoked with
53005322

53015323
The dollar sign characters in the return value of the `replace` function argument are not special at all.
53025324

5303-
This method requires the PCRE library enabled in Nginx. ([Known Issue With Special PCRE Sequences](#special-pcre-sequences)).
5325+
This method requires the PCRE library enabled in Nginx. ([Known Issue With Special Escaping Sequences](#special-escaping-sequences)).
53045326

53055327
This feature was first introduced in the `v0.2.1rc13` release.
53065328

@@ -5338,7 +5360,7 @@ Here is some examples:
53385360
-- n == 2
53395361
```
53405362

5341-
This method requires the PCRE library enabled in Nginx. ([Known Issue With Special PCRE Sequences](#special-pcre-sequences)).
5363+
This method requires the PCRE library enabled in Nginx. ([Known Issue With Special Escaping Sequences](#special-escaping-sequences)).
53425364

53435365
This feature was first introduced in the `v0.2.1rc15` release.
53445366

doc/HttpLuaModule.wiki

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ The cosockets are currently also disabled in the [[#init_by_lua|init_by_lua*]] a
609609

610610
There exists a work-around, however, when the original context does *not* need to wait for the cosocket results. That is, creating a 0-delay timer via the [[#ngx.timer.at|ngx.timer.at]] API and do the cosocket results in the timer handler, which runs asynchronously as to the original context creating the timer.
611611

612-
== Special PCRE Sequences ==
612+
== Special Escaping Sequences ==
613613
PCRE sequences such as <code>\d</code>, <code>\s</code>, or <code>\w</code>, require special attention because in string literals, the backslash character, <code>\</code>, is stripped out by both the Lua language parser and by the Nginx config file parser before processing. So the following snippet will not work as expected:
614614

615615
<geshi lang="nginx">
@@ -700,6 +700,24 @@ Mixing SSI with ngx_lua in the same Nginx request is not supported at all. Just
700700
701701
Certain Lua APIs provided by ngx_lua do not work in Nginx's SPDY mode yet: [[#ngx.location.capture|ngx.location.capture]], [[#ngx.location.capture_multi|ngx.location.capture_multi]], and [[#ngx.req.socket|ngx.req.socket]].
702702
703+
== Missing data on short circuited requests ==
704+
705+
Nginx may terminate a request early with (at least):
706+
707+
* 400 (Bad Request)
708+
* 405 (Not Allowed)
709+
* 408 (Request Timeout)
710+
* 414 (Request URI Too Large)
711+
* 494 (Request Headers Too Large)
712+
* 499 (Client Closed Request)
713+
* 500 (Internal Server Error)
714+
* 501 (Not Implemented)
715+
716+
This means that phases that normally run are skipped, such as the rewrite or
717+
access phase. This also means that later phases that are run regardless, e.g.
718+
[[#log_by_lua|log_by_lua]], will not have access to information that is normally set in those
719+
phases.
720+
703721
= TODO =
704722
705723
* add <code>*_by_lua_block</code> directives for existing <code>*_by_lua</code> directives so that we put literal Lua code directly in curly braces instead of an nginx literal string. For example,
@@ -4244,7 +4262,7 @@ The <code>ctx</code> table argument combined with the <code>a</code> regex modif
42444262
42454263
Note that, the <code>options</code> argument is not optional when the <code>ctx</code> argument is specified and that the empty Lua string (<code>""</code>) must be used as placeholder for <code>options</code> if no meaningful regex options are required.
42464264
4247-
This method requires the PCRE library enabled in Nginx. ([[#Special PCRE Sequences|Known Issue With Special PCRE Sequences]]).
4265+
This method requires the PCRE library enabled in Nginx. ([[#Special Escaping Sequences|Known Issue With Special Escaping Sequences]]).
42484266
42494267
To confirm that PCRE JIT is enabled, activate the Nginx debug log by adding the <code>--with-debug</code> option to Nginx or ngx_openresty's <code>./configure</code> script. Then, enable the "debug" error log level in <code>error_log</code> directive. The following message will be generated if PCRE JIT is enabled:
42504268
@@ -4374,7 +4392,7 @@ The optional <code>options</code> argument takes exactly the same semantics as t
43744392
43754393
The current implementation requires that the iterator returned should only be used in a single request. That is, one should ''not'' assign it to a variable belonging to persistent namespace like a Lua package.
43764394
4377-
This method requires the PCRE library enabled in Nginx. ([[#Special PCRE Sequences|Known Issue With Special PCRE Sequences]]).
4395+
This method requires the PCRE library enabled in Nginx. ([[#Special Escaping Sequences|Known Issue With Special Escaping Sequences]]).
43784396
43794397
This feature was first introduced in the <code>v0.2.1rc12</code> release.
43804398
@@ -4433,7 +4451,7 @@ When the <code>replace</code> argument is of type "function", then it will be in
44334451
44344452
The dollar sign characters in the return value of the <code>replace</code> function argument are not special at all.
44354453
4436-
This method requires the PCRE library enabled in Nginx. ([[#Special PCRE Sequences|Known Issue With Special PCRE Sequences]]).
4454+
This method requires the PCRE library enabled in Nginx. ([[#Special Escaping Sequences|Known Issue With Special Escaping Sequences]]).
44374455
44384456
This feature was first introduced in the <code>v0.2.1rc13</code> release.
44394457
@@ -4466,7 +4484,7 @@ Here is some examples:
44664484
-- n == 2
44674485
</geshi>
44684486
4469-
This method requires the PCRE library enabled in Nginx. ([[#Special PCRE Sequences|Known Issue With Special PCRE Sequences]]).
4487+
This method requires the PCRE library enabled in Nginx. ([[#Special Escaping Sequences|Known Issue With Special Escaping Sequences]]).
44704488
44714489
This feature was first introduced in the <code>v0.2.1rc15</code> release.
44724490

0 commit comments

Comments
 (0)