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 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 = "My great page" > >  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. >