According to the Compression section of the documentation of Net::HTTP, it should automatically uncompress compressed responses. However, when I tried with a number of JSON requests with different servers, I am not getting automatic decompression.
require 'net/http'
uri = URI("http://yourhost.com")
http = Net::HTTP.new(uri.host, uri.port)
res = http.get(uri.request_uri)
Got the same thing and also this error when the block ends :
/usr/lib/ruby/1.9.1/net/http.rb:1032:in initialize': can't convert Net::ReadAdapter into String (TypeError) from /usr/lib/ruby/1.9.1/net/http.rb:1032:in new'
from /usr/lib/ruby/1.9.1/net/http.rb:1032:in block in get' from /usr/lib/ruby/1.9.1/net/http.rb:1322:in block (2 levels) in transport_request'
from /usr/lib/ruby/1.9.1/net/http.rb:2671:in reading_body' from /usr/lib/ruby/1.9.1/net/http.rb:1321:in block in transport_request'
from /usr/lib/ruby/1.9.1/net/http.rb:1316:in catch' from /usr/lib/ruby/1.9.1/net/http.rb:1316:in transport_request'
from /usr/lib/ruby/1.9.1/net/http.rb:1293:in request' from /usr/lib/ruby/1.9.1/net/http.rb:1286:in block in request'
from /usr/lib/ruby/1.9.1/net/http.rb:745:in start' from /usr/lib/ruby/1.9.1/net/http.rb:1284:in request'
from /usr/lib/ruby/1.9.1/net/http.rb:1026:in get' from téléphones_LEP.rb:11:in block in
'
This is when using ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux].
It works on ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-linux]