I am trying to ping a server using Rails. I found this
Check HTTP Status Code in Rails
but I get this error while running this code,
require 'net/http'
http = Net::HTTP.new('www.google.com',80)
response = http.request_get('/')
p response.status
Error:
`<main>': undefined method `status' for #<Net::HTTPFound 302 Found readbody=true> (NoMethodError)
Why? And why does google returns me a 302 code?? Shouldn't it be 200?
Use response.code if you are using ruby 1.9.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With