lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Mar 15, 2005, at 04:58, Rici Lake wrote:

You need to format the stream by sending a gzip header prior to the compressed content. (You will also need to provide a trailer containing a CRC.)

Yes. It turns out that the answer, like in many case, is 31.

 It's annoying, isn't it? And really badly documented.

Well... as Tiago Dionizio pointed out:

"The answer you are looking for is in the zlib.h header (the main source
for documentation on the library for me :)."

Most of the implementations I've seen are cargo culted from other implementations.

To quote Tiago Dionizio once more, the cult in question goes something like this:

"To do that in lua, use the following command:

local aCompressedContent = zlib.compress( aContent, nil, nil, 15 + 16 )

nil values are given for some parameters so they use the default values,
the 15+16 is the windowBits value: 15 is the default value, and also the
maximum value, and the 16 is to tell the zlib library to write a gzip
header as stated in the documentation."

Works like a charm once you know the proper incantation :)

Check LWResponse's compressContent() method for all the gory details:

http://dev.alt.textdrive.com/file/LW/LWResponse.lua

You might find this page a useful place to start. It's not the best, but I only googled for three minutes: http://www.cherrypy.org/wiki/NotesOnTicket59

CherryPy? CherryPy! We like CherryPy!

LuaWeb (aka LW) is going to have a somewhat similar way to publish objects... perhaps... one day :)

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/