I have ruby-1.9.3-p327 with zlib installed. localhost:80 is the nginx simple test page.
require "net/http"
=> true
Net::HTTP::HAVE_ZLIB
=> true
res = Net::HTTP.start("localhost", "80") do |http|
req = Net::HTTP::Get.new "/"
req["accept-encoding"] = "gzip"
http.request req
end
=> #<Net::HTTPOK 200 OK readbody=true>
res.get_fields "content-encoding"
=> ["gzip"]
res.body
=> "\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x03\xEC\xBDi..."
The body was not decoded. Why?
If you use
http.getit should decode it automaticlly, but it looks likerequestmight not do it for you.There clearly is code to decompress the gzip request here, but only for the
getmethod:https://github.com/ruby/ruby/blob/v1_9_3_327/lib/net/http.rb#L1031