From a8e1f16f060495bf36c158f6b3b8ccb98524fddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?agentzh=20=28=E7=AB=A0=E4=BA=A6=E6=98=A5=29?= Date: Sat, 16 Jun 2012 13:27:24 +0800 Subject: [PATCH] docs: redocumented the "inclusive" option for the cosocket:receiveuntil method. --- README | 29 ++++++++++++++++++++--------- README.markdown | 23 ++++++++++++++++------- doc/HttpLuaModule.wiki | 18 ++++++++++++++++-- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/README b/README index 1378e422..ab4ee6a9 100644 --- a/README +++ b/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()* diff --git a/README.markdown b/README.markdown index e7b7d927..fb16fa2a 100644 --- a/README.markdown +++ b/README.markdown @@ -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 ------------- diff --git a/doc/HttpLuaModule.wiki b/doc/HttpLuaModule.wiki index 5586f009..c1d64508 100644 --- a/doc/HttpLuaModule.wiki +++ b/doc/HttpLuaModule.wiki @@ -3401,7 +3401,7 @@ It is important here to call the [[#tcpsock:settimeout|settimeout]] method ''bef 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*'' @@ -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 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()''