docs: redocumented the "inclusive" option for the cosocket:receiveuntil method.

This commit is contained in:
agentzh (章亦春) 2012-06-16 13:27:24 +08:00
Родитель c4d5e3a24d
Коммит a8e1f16f06
3 изменённых файлов: 52 добавлений и 18 удалений

29
README
Просмотреть файл

@ -3796,20 +3796,13 @@ Nginx API for Lua
This feature was first introduced in the "v0.5.0rc1" release.
tcpsock:receiveuntil
syntax: *iterator = tcpsock:receiveuntil(pattern)*
syntax: *iterator = tcpsock:receiveuntil(pattern, options?)*
context: *rewrite_by_lua*, access_by_lua*, content_by_lua**
This method returns an iterator Lua function that can be called to read
the data stream until it sees the specified pattern or an error occurs.
An optional option table can be given as a second argument, which
support the options:
* "inclusive" specify wether the pattern itself should be returned
as part of the matched data.
Here is an example for using this method to read a data stream with the
boundary sequence "--abcedhb":
@ -3895,7 +3888,25 @@ Nginx API for Lua
iterator function (note that the "receiveuntil" call is irrelevant
here).
This feature was first introduced in the "v0.5.0rc1" release.
Since the "v0.5.1" release, this method also takes an optional "options"
table argument to control the behavior. The following options are
supported:
* "inclusive"
The "inclusive" takes a boolean value to control whether to include the
pattern string in the returned data string. Default to "false". For
example,
local reader = tcpsock:receiveuntil("_END_", { inclusive = true })
local data = reader()
ngx.say(data)
Then for the input data stream "hello world _END_ blah blah blah", then
the example above will output "hello world _END_", including the pattern
string "_END_" itself.
This method was first introduced in the "v0.5.0rc1" release.
tcpsock:close
syntax: *ok, err = tcpsock:close()*

Просмотреть файл

@ -3520,17 +3520,12 @@ This feature was first introduced in the `v0.5.0rc1` release.
tcpsock:receiveuntil
--------------------
**syntax:** *iterator = tcpsock:receiveuntil(pattern)*
**syntax:** *iterator = tcpsock:receiveuntil(pattern, options?)*
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua**
This method returns an iterator Lua function that can be called to read the data stream until it sees the specified pattern or an error occurs.
An optional option table can be given as the second argument, which support the options:
* `inclusive`
specify wether the pattern itself should be returned as part of the matched data
Here is an example for using this method to read a data stream with the boundary sequence `--abcedhb`:
@ -3598,7 +3593,21 @@ Timeout for the iterator function's reading operation is controlled by the [lua_
It is important here to call the [settimeout](http://wiki.nginx.org/HttpLuaModule#tcpsock:settimeout) method *before* calling the iterator function (note that the `receiveuntil` call is irrelevant here).
This feature was first introduced in the `v0.5.0rc1` release.
Since the `v0.5.1` release, this method also takes an optional `options` table argument to control the behavior. The following options are supported:
* `inclusive`
The `inclusive` takes a boolean value to control whether to include the pattern string in the returned data string. Default to `false`. For example,
local reader = tcpsock:receiveuntil("_END_", { inclusive = true })
local data = reader()
ngx.say(data)
Then for the input data stream `"hello world _END_ blah blah blah"`, then the example above will output `hello world _END_`, including the pattern string `_END_` itself.
This method was first introduced in the `v0.5.0rc1` release.
tcpsock:close
-------------

Просмотреть файл

@ -3401,7 +3401,7 @@ It is important here to call the [[#tcpsock:settimeout|settimeout]] method ''bef
This feature was first introduced in the <code>v0.5.0rc1</code> release.
== tcpsock:receiveuntil ==
'''syntax:''' ''iterator = tcpsock:receiveuntil(pattern)''
'''syntax:''' ''iterator = tcpsock:receiveuntil(pattern, options?)''
'''context:''' ''rewrite_by_lua*, access_by_lua*, content_by_lua*''
@ -3474,7 +3474,21 @@ Timeout for the iterator function's reading operation is controlled by the [[#lu
It is important here to call the [[#tcpsock:settimeout|settimeout]] method ''before'' calling the iterator function (note that the <code>receiveuntil</code> call is irrelevant here).
This feature was first introduced in the <code>v0.5.0rc1</code> release.
Since the <code>v0.5.1</code> release, this method also takes an optional <code>options</code> table argument to control the behavior. The following options are supported:
* <code>inclusive</code>
The <code>inclusive</code> takes a boolean value to control whether to include the pattern string in the returned data string. Default to <code>false</code>. For example,
<geshi lang="lua">
local reader = tcpsock:receiveuntil("_END_", { inclusive = true })
local data = reader()
ngx.say(data)
</geshi>
Then for the input data stream <code>"hello world _END_ blah blah blah"</code>, then the example above will output <code>hello world _END_</code>, including the pattern string <code>_END_</code> itself.
This method was first introduced in the <code>v0.5.0rc1</code> release.
== tcpsock:close ==
'''syntax:''' ''ok, err = tcpsock:close()''