Apache mod_lua中的读取响应体

Apache mod_lua中的读取响应体,apache,lua,mod-lua,Apache,Lua,Mod Lua,我正在用Apache+mod_lua制作一个简单的“输出”过滤器原型。如何通过LUA读取应用的其他本机输出过滤器末尾的响应体?例如,我可以得到将发送给客户的实际响应吗?手册对此有一些很好的指导: 使用通过实现的Lua筛选器功能修改内容 LuaInputFilter或LuaOutput Filter设计为三级 非阻塞函数使用协同路由来挂起和恢复 铲斗沿过滤链向下输送时起作用。核心结构 这一职能的核心是: function filter(r) -- Our first yield is t

我正在用Apache+mod_lua制作一个简单的“输出”过滤器原型。如何通过LUA读取应用的其他本机输出过滤器末尾的响应体?例如,我可以得到将发送给客户的实际响应吗?

手册对此有一些很好的指导:

使用通过实现的Lua筛选器功能修改内容 LuaInputFilter或LuaOutput Filter设计为三级 非阻塞函数使用协同路由来挂起和恢复 铲斗沿过滤链向下输送时起作用。核心结构 这一职能的核心是:

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