Hi,
We only support gzip compression at the moment.
As for gzip, if the attachment upload request has "Content-Encoding: gzip",
couch will only look at content-type and completely ignore Content-Encoding
when deciding whether to compress or not the attachment. Therefore
compressing the already compressed data.
I can submit a fix by the end of the week. I have limited computer/internet
access until then.
regards,
On Wed, Mar 17, 2010 at 10:23 PM, Paul Davis <paul.joseph.davis@gmail.com>wrote:
> Do we support deflate compression? I only remember gzip being part of
> the compressible attachments patch.
>
> Paul
>
> On Wed, Mar 17, 2010 at 5:53 PM, Brian Candler <B.Candler@pobox.com>
> wrote:
> > On Wed, Mar 17, 2010 at 01:53:57PM -0700, John Merrells wrote:
> >> Some pseudo ruby
> >
> > OK, I've turned that into some real ruby:
> >
> > ------------------------------------------------------------------------
> > require 'zlib'
> > require 'rubygems'
> > require 'restclient'
> > require 'json'
> > begin
> > DB = "http://127.0.0.1:5984/testdb"
> >
> > RestClient.delete(DB) rescue nil
> > RestClient.put(DB, "")
> > rev = JSON.parse(RestClient.put("#{DB}/doc1", "{}"))['rev']
> >
> > html = "<html>My great page</html>"
> >
> > attachment= Zlib::Deflate.deflate(html)
> > headers = {'Content-Encoding'=>'deflate',:content_type=>'text/html'}
> > RestClient.put("#{DB}/doc1/attach1?rev=#{rev}", attachment, headers)
> > p RestClient.get("#{DB}/doc1/attach1")
> >
> > rescue RestClient::RequestFailed => e
> > puts e.message
> > puts e.http_body
> > end
> > ------------------------------------------------------------------------
> >
> > tcpdump shows that 'Content-Encoding: deflate' is indeed sent with the
> > request, but as John says, the response is the compressed doc but without
> > a corresponding 'Content-Encoding: deflate' header, so any browser would
> > treat it as garbage.
> >
> > I then tried it with a json doc rather than attachment:
> >
> > ------------------------------------------------------------------------
> > require 'zlib'
> > require 'rubygems'
> > require 'restclient'
> > require 'json'
> > begin
> > DB = "http://127.0.0.1:5984/testdb"
> >
> > RestClient.delete(DB) rescue nil
> > RestClient.put(DB, "")
> >
> > json = '{"foo":"bar"}'
> > doc = Zlib::Deflate.deflate(json)
> > headers =
> {'Content-Encoding'=>'deflate',:content_type=>'application/json'}
> > rev = JSON.parse(RestClient.put("#{DB}/doc2", doc, headers))['rev']
> >
> > # doesn't get here; the uploaded doc is rejected as invalid
> > p RestClient.get("#{DB}/doc2")
> >
> > rescue RestClient::RequestFailed => e
> > puts e.message
> > puts e.http_body
> > end
> > ------------------------------------------------------------------------
> >
> > The doc is rejected as invalid JSON.
> >
> > Perhaps I simply misunderstand how the Content-Encoding: header is
> supposed
> > to work?
> >
> > Regards,
> >
> > Brian.
> >
>
--
Filipe David Manana,
fdmanana@gmail.com
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."
|