Ruby 获取 HTTP 回应的编码和内容

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

require 'net/http'
response = Net::HTTP.get_response('www.oschina.net, '/code/list')
response.code          # => "200"
response.body.size     # => 21835
response['Content-type']

puts response.body[0,200]