On Wednesday, 23 May 2012 20:35:56 UTC+5:30, agentzh wrote:
> Hello!
>
>
>
> Because someone is willing to sponsor the development work, I'm going
>
> to work on the output body filter support for the ngx_lua module in
>
> the next week or so. And here is a proposal for the related API:
>
>
>
> * Lua code is hooked up via the body_filter_by_lua and
>
> body_filter_by_lua_filter directives.
>
> * Input data chunk is passed via ngx.arg[1] and a boolean flag
>
> indicating the end of the output stream is passed via ngx.arg[2].
>
> * Output data chunk is returned directly by the Lua code chunk via the
>
> "return" statement. It can be either a Lua string or an array-shaped
>
> Lua table holding the string pieces. If nil is returned then there
>
> will be no output to the downstream output filters.
>
> * ngx.exit(ngx.ERROR) can be used to abort the output stream.
>
> * For now, ngx.print, ngx.say, ngx.flush, ngx.location.*,
>
> ngx.socket.*, ngx.req.socket, and other special APIs that may yield
>
> the current Lua coroutine will be disabled in this context.
>
>
>
> Here is a simple example for this API:
>
>
>
> location / {
>
> proxy_pass ...;
>
>
>
> body_filter_by_lua '
>
> local chunk, eof = ngx.arg[1], ngx.arg[2]
>
> local new_chunk, err = my_process_chunk(chunk, eof)
>
> if err then
>
> ngx.log(ngx.ERR, "failed to process the data chunk: ", err)
>
> return ngx.exit(ngx.ERROR)
>
> end
>
> return new_chunk
>
> ';
>
> }
>
>
>
> Comments will be highly appreciated ;)
>
>
>
> Thanks!
>
> -agentzh
is there any specific reason to disable ngx.print, ngx.say, ngx.flush, ngx.location.*,
ngx.socket.*, ngx.req.socket, and other special APIs ????
Please clear me on this
thanks