[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lzlib usage
- From: Phoenix Sol <phoenix@...>
- Date: Thu, 28 Jan 2010 14:21:06 -0600
On Thu, Jan 28, 2010 at 1:44 PM, Petite Abeille <email@example.com>
Tiago Dionizio's lzlib?
On Jan 28, 2010, at 8:40 PM, Phoenix Sol wrote:
> Anyone have any intel on this library, lzlib
Yes, that one; sorry.
If yes, here is an usage example:
local ok, zlib = pcall( require, 'zlib' )
if ok and zlib then
local aContent = tostring( aResponse.content )
local zContent = zlib.compress( aContent, 9, nil, 15 + 16 )
if zContent:len() < aContent:len() then
aResponse.header[ 'content-encoding' ] = 'gzip'
aResponse.header[ 'etag' ] = nil
aResponse.content = zContent
Right, I had no problem trying out compress() and uncompress() (although the options are still kinda mysterious).
What I'm trying to understand is how to process in a stream, from a source to a sink without necessarily holding the entire message body in a buffer; the userdata returned by compressobj() and decompressobj() seem to be what I'm after but so far I don't quite grok them.
Thanks for your help.