httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Bannister <>
Subject Re: Ideas for an output filter for mod_lua
Date Thu, 23 Aug 2012 21:32:20 GMT
On 23 Aug 2012, at 11:45, Daniel Gruno <> wrote:
> On 08/23/2012 12:02 AM, Tim Bannister wrote:
>> I don't know if this is another way of phrasing Nick's question or not, but would
I be able to implement gzip Transfer-Encoding: just using Lua and this new directive?
>> I found (bug 52860) it a bit tricky to achieve in C, so I think it could be harder
still with the extra limitations of the Lua environment. My C code uses AP_FTYPE_TRANSCODE
which I think is the right choice but few modules get involved at this filtering stage.
> So yes, theoretically you should be able to implement decompression this
> way, by doing something along the lines of this (totally just making it up):
>> -----------------------------------------------------<
> local zip = require "zlib" -- or something...
> function gzip_handle(r)
>    r.headers_out['Transfer-Encoding'] = "gzip" -- or ?
>    do_magic_header_stuff_here() -- add header data
>    coroutine.yield() -- yield and wait for buckets
>    while (buffer) do  -- for each bucket, deflate it
>        local deflated = zip.deflate(buffer)
>        coroutine.yield(deflated) -- pass on new data
>    end
>    append_tail_to_output() -- pass on a tail if needed
> end
>> -----------------------------------------------------<

My patch is for implementing gzip compression by httpd, not decompression, but the code will
look pretty similar.

That's quite neat, then. I will try to make an actual implementation in Lua.
The part I found difficult was the interaction with the second transfer-encoding, “chunked”.
Using gzip Transfer-Encoding: implies using chunked, because we want to shorten the response
and this means that the Content-Length definitely doesn't match the size of the HTTP response

Tim Bannister –

View raw message