2
我想使用Rails来ping一个服务器。我发现这个使用Rails Ping一个服务器
Check HTTP Status Code in Rails
但在运行此代码,我得到这个错误,
require 'net/http'
http = Net::HTTP.new('www.google.com',80)
response = http.request_get('/')
p response.status
错误:
`<main>': undefined method `status' for #<Net::HTTPFound 302 Found readbody=true> (NoMethodError)
为什么?为什么谷歌返回给我一个302代码?它不应该是200吗?