我是 Ruby 编程的新手。我正在尝试使用 HTTP GET 请求获取 google XRDS,但遇到 NoMethodError (undefined method `set_body_internal') 错误。下面是我的代码。任何帮助深表感谢。
require "net/https"
require "uri"
class OpenidController < ApplicationController
def getOpenIdXRD
print "Hello...\n"
uri = URI.parse("https://gmail.com/.well-known/host-meta")
print "Hello...1\n"
# Shortcut
#response1 = Net::HTTP.get_response(uri)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
print "Hello...2\n"
File response1 = http.request(request)
print "Hello...3\n"
response1.body
response1.status
# Will print response.body
# Net::HTTP.get_print(uri)
end
end
这是我的输出:
2ms 内完成(查看:1,DB:72)| 200 OK [IP] 你好... 你好...1 你好...2 吨] ←[4;36;1mSQL (188.1ms)←[0m ←[0;1mSET SQL_AUTO_IS_NULL=0←[0m 处理 OpenidController#getOpenIdXRD (for 127.0.0.1 at 2013-06-25 20:28:04) [得到] 参数:{"user"=>""} NoMethodError(未定义的方法 `set_body_internal' for #):