From: Daniel Gruno Date: Mon, 27 Aug 2012 07:29:31 +0000 (+0000) Subject: Rearranging a section so validate-xml will stay happy (for whatever reason) X-Git-Tag: 2.5.0-alpha~6379 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=edf0f80ad9066e30d502c903fd40ec356d1b3a8d;p=apache Rearranging a section so validate-xml will stay happy (for whatever reason) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1377592 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/mod_lua.xml b/docs/manual/mod/mod_lua.xml index a9ddfb9abb..f0175eac2d 100644 --- a/docs/manual/mod/mod_lua.xml +++ b/docs/manual/mod/mod_lua.xml @@ -693,6 +693,46 @@ r:parsebody([sizeLimit]) -- parse the request body as a POST and return a lua ta

(Other HTTP status codes are not yet implemented.)

+
+ Modifying contents with Lua filters +

+ Filter functions implemented via LuaInputFilter + or LuaOutputFilter are designed as + three-stage non-blocking functions using coroutines to suspend and resume a + function as buckets are sent down the filter chain. The core structure of + such a function is: +

+ +function filter(r) + -- Our first yield is to signal that we are ready to receive buckets. + -- Before this yield, we can set up our environment, check for conditions, + -- and, if we deem it necessary, decline filtering a request alltogether: + if something_bad then + return -- This would skip this filter. + end + -- Regardless of whether we have data to prepend, a yield MUST be called here. + -- Note that only output filters can prepend data. Input filters must use the + -- final stage to append data to the content. + coroutine.yield([optional header to be prepended to the content]) + + -- After we have yielded, buckets will be sent to us, one by one, and we can + -- do whatever we want with them and then pass on the result. + -- Buckets are stored in the global variable 'bucket', so we create a loop + -- that checks if 'bucket' is not nil: + while bucket ~= nil do + local output = mangle(bucket) -- Do some stuff to the content + coroutine.yield(output) -- Return our new content to the filter chain + end + + -- Once the buckets are gone, 'bucket' is set to nil, which will exit the + -- loop and land us here. Anything extra we want to append to the content + -- can be done by doing a final yield here. Both input and output filters + -- can append data to the content in this phase. + coroutine.yield([optional footer to be appended to the content]) +end + +
+ LuaRoot Specify the base path for resolving relative paths for mod_lua directives @@ -1300,45 +1340,6 @@ information. -
- Modifying contents with Lua filters -

- Filter functions implemented via LuaInputFilter - or LuaOutputFilter are designed as - three-stage non-blocking functions using coroutines to suspend and resume a - function as buckets are sent down the filter chain. The core structure of - such a function is: -

- -function filter(r) - -- Our first yield is to signal that we are ready to receive buckets. - -- Before this yield, we can set up our environment, check for conditions, - -- and, if we deem it necessary, decline filtering a request alltogether: - if something_bad then - return -- This would skip this filter. - end - -- Regardless of whether we have data to prepend, a yield MUST be called here. - -- Note that only output filters can prepend data. Input filters must use the - -- final stage to append data to the content. - coroutine.yield([optional header to be prepended to the content]) - - -- After we have yielded, buckets will be sent to us, one by one, and we can - -- do whatever we want with them and then pass on the result. - -- Buckets are stored in the global variable 'bucket', so we create a loop - -- that checks if 'bucket' is not nil: - while bucket ~= nil do - local output = mangle(bucket) -- Do some stuff to the content - coroutine.yield(output) -- Return our new content to the filter chain - end - - -- Once the buckets are gone, 'bucket' is set to nil, which will exit the - -- loop and land us here. Anything extra we want to append to the content - -- can be done by doing a final yield here. Both input and output filters - -- can append data to the content in this phase. - coroutine.yield([optional footer to be appended to the content]) -end - -