Attached is a patch that adds gzip support to mochiweb, it is
generated from the build of mochiweb that is currently included with
CouchDB. It only adds gzip support for non-chunked data. In order to
really support chunked gzip'ed data I would need to add some new API*,
I actually have a rough cut of it, but the changes in CouchDB are
moderately tricky, so I don't have high confidence it is actually
correct, I will probably build a smaller test app to get that working
then make the changes to CouchDB.
Be kind with this patch, it is the first erlang code I have ever written ;-)
Louis
* Technically you can gzip each individual chunk since gzip data can
be catted together to result in a compressed file that decompresses to
the cat of the individual compressed files. The problem with doing
that is that the dictionary is very small, so you get really bad
compression if you do that, especially with something like CouchDB
where each record is sent in a separate chunk and is likely to contain
a lot common strings. So in order to make that happen I need to pass
around state between between transmitting chunks. The downside of that
is that it requires a new API, the upside is that that would allow for
coalescing chunks into to specific sizes even when not doing
compression.
I like the way you put this Bob.
And, Louis, if the implementation is solid, it does sound like it
could be a good option in CouchDB.
--
Chris Anderson
http://jchris.mfdz.com