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

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]

编程技巧