【发布时间】:2024-01-10 23:00:01
【问题描述】:
我有 ruby-1.9.3-p327 安装了 zlib。 localhost:80是nginx简单测试页面。
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..."
尸体没有被解码。为什么?
【问题讨论】:
-
切换到 ruby-head (2.0) 后生效