From: drbrain@...7.net Date: 2014-01-30T20:52:33+00:00 Subject: [ruby-core:60362] [ruby-trunk - Bug #9467] [Feedback] Net::HTTP does unzip zipped content Issue #9467 has been updated by Eric Hodel. Tracker changed from Backport to Bug Project changed from Backport200 to ruby-trunk Category set to lib Status changed from Open to Feedback Priority changed from High to Normal I can't reproduce. The URI you've given is correctly decompressed by Net::HTTP using ruby 2.0.0: $ cat test.rb require 'net/http' require 'pp' uri = URI("http://vimeo.com/api/oembed.json?url=http://vimeo.com/69655841&width=150") http = Net::HTTP.new(uri.host, uri.port) http.set_debug_output $stderr res = http.get(uri.request_uri) pp res.to_hash p res.body[0, 30] $ ruby20 -v test.rb ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0] opening connection to vimeo.com:80... opened <- "GET /api/oembed.json?url=http://vimeo.com/69655841&width=150 HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: vimeo.com\r\n\r\n" -> "HTTP/1.1 200 OK\r\n" -> "Server: Apache\r\n" -> "Access-Control-Allow-Origin: *\r\n" -> "Access-Control-Allow-Headers: X-Requested-With\r\n" -> "Expires: Thu, 30 Jan 2014 20:52:07 GMT\r\n" -> "Last-Modified: Thu, 30 Jan 2014 20:12:02 GMT\r\n" -> "Etag: \"215c14df5b7b774ff7b23cfb02b34da62c9ec022\"\r\n" -> "X-UA-Compatible: IE=edge\r\n" -> "X-DNS-Prefetch-Control: on\r\n" -> "Vary: Accept-Encoding\r\n" -> "Content-Encoding: gzip\r\n" -> "Content-Type: application/json\r\n" -> "Content-Length: 745\r\n" -> "Accept-Ranges: bytes\r\n" -> "Date: Thu, 30 Jan 2014 20:51:07 GMT\r\n" -> "X-Varnish: 2058928850\r\n" -> "Age: 0\r\n" -> "Via: 1.1 varnish\r\n" -> "X-Varnish-Cache: 0\r\n" -> "Connection: close\r\n" -> "X-VServer: 10.90.128.147\r\n" -> "\r\n" reading 745 bytes... -> "\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x03[snipped gzip response]" read 745 bytes Conn close {"server"=>["Apache"], "access-control-allow-origin"=>["*"], "access-control-allow-headers"=>["X-Requested-With"], "expires"=>["Thu, 30 Jan 2014 20:52:07 GMT"], "last-modified"=>["Thu, 30 Jan 2014 20:12:02 GMT"], "etag"=>["\"215c14df5b7b774ff7b23cfb02b34da62c9ec022\""], "x-ua-compatible"=>["IE=edge"], "x-dns-prefetch-control"=>["on"], "vary"=>["Accept-Encoding"], "content-type"=>["application/json"], "content-length"=>["745"], "accept-ranges"=>["bytes"], "date"=>["Thu, 30 Jan 2014 20:51:07 GMT"], "x-varnish"=>["2058928850"], "age"=>["0"], "via"=>["1.1 varnish"], "x-varnish-cache"=>["0"], "connection"=>["close"], "x-vserver"=>["10.90.128.147"]} "{\"type\":\"video\",\"version\":\"1.0" ---------------------------------------- Bug #9467: Net::HTTP does unzip zipped content https://bugs.ruby-lang.org/issues/9467#change-44844 * Author: Amitav Mohanty * Status: Feedback * Priority: Normal * Assignee: Amitav Mohanty * Category: lib * Target version: * ruby -v: ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux] * Backport: ---------------------------------------- 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) You can test hitting http://vimeo.com/api/oembed.json?url=http://vimeo.com/69655841&width=150 -- http://bugs.ruby-lang.org/