Using open-uri Ruby library to open http websites is really easy:
begin io_thing = open(self.check_url.to_s) io_thing.status == '200' rescue Exception => e false end
Things get itchy when we want to visit a HTTPS (SSL) self-signed website. Some of them have them corrupted (or expired). Open-uri raises an exception when it occures one of them. To skip certificates testing and get the page we need to turn off certificates verification:
module OpenSSL module SSL remove_const :VERIFY_PEER end end OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
However remember to do this carefully, because this can we a security thread to your software.