Skip to content

Commit

Permalink
doc: ngx.var: documented the values for undefined and uninitialized n…
Browse files Browse the repository at this point in the history
…ginx variables. thanks Sean Johnson for asking for this explanation in #595.
  • Loading branch information
agentzh committed Nov 5, 2015
1 parent ea33435 commit c317742
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.markdown
Expand Up @@ -2855,7 +2855,7 @@ many others are not, like `$query_string`, `$arg_PARAMETER`, and `$http_NAME`.
Nginx regex group capturing variables `$1`, `$2`, `$3`, and etc, can be read by this
interface as well, by writing `ngx.var[1]`, `ngx.var[2]`, `ngx.var[3]`, and etc.

Setting `ngx.var.Foo` to a `nil` value will unset the `$Foo` Nginx variable.
Setting `ngx.var.Foo` to a `nil` value will unset the `$Foo` Nginx variable.

```lua

Expand All @@ -2872,6 +2872,8 @@ Setting `ngx.var.Foo` to a `nil` value will unset the `$Foo` Nginx variable.

to prevent (temporary) memory leaking within the current request's lifetime. Another way of caching the result is to use the [ngx.ctx](#ngxctx) table.

Undefined NGINX variables are evaluated to `nil` while uninitialized (but defined) NGINX variables are evaluated to an empty Lua string.

This API requires a relatively expensive metamethod call and it is recommended to avoid using it on hot code paths.

[Back to TOC](#nginx-api-for-lua)
Expand Down
4 changes: 3 additions & 1 deletion doc/HttpLuaModule.wiki
Expand Up @@ -2285,7 +2285,7 @@ many others are not, like <code>$query_string</code>, <code>$arg_PARAMETER</code
Nginx regex group capturing variables <code>$1</code>, <code>$2</code>, <code>$3</code>, and etc, can be read by this
interface as well, by writing <code>ngx.var[1]</code>, <code>ngx.var[2]</code>, <code>ngx.var[3]</code>, and etc.
Setting <code>ngx.var.Foo</code> to a <code>nil</code> value will unset the <code>$Foo</code> Nginx variable.
Setting <code>ngx.var.Foo</code> to a <code>nil</code> value will unset the <code>$Foo</code> Nginx variable.
<geshi lang="lua">
ngx.var.args = nil
Expand All @@ -2300,6 +2300,8 @@ Setting <code>ngx.var.Foo</code> to a <code>nil</code> value will unset the <cod
to prevent (temporary) memory leaking within the current request's lifetime. Another way of caching the result is to use the [[#ngx.ctx|ngx.ctx]] table.
Undefined NGINX variables are evaluated to `nil` while uninitialized (but defined) NGINX variables are evaluated to an empty Lua string.
This API requires a relatively expensive metamethod call and it is recommended to avoid using it on hot code paths.
== Core constants ==
Expand Down

0 comments on commit c317742

Please sign in to comment.