Sha256: 6e1b49937051ee49a39e98573c1c6b5b88ce5a5648da64cfaca6c7be2f57d25d
Contents?: true
Size: 902 Bytes
Versions: 20
Compression:
Stored size: 902 Bytes
Contents
module CypressRails class Server class Checker TRY_HTTPS_ERRORS = [EOFError, Net::ReadTimeout, Errno::ECONNRESET].freeze def initialize(host, port) @host, @port = host, port @ssl = false end def request(&block) ssl? ? https_request(&block) : http_request(&block) rescue *TRY_HTTPS_ERRORS res = https_request(&block) @ssl = true res end def ssl? @ssl end private def http_request(&block) make_request(read_timeout: 2, &block) end def https_request(&block) make_request(**ssl_options, &block) end def make_request(**options, &block) Net::HTTP.start(@host, @port, options.merge(max_retries: 0), &block) end def ssl_options {use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE} end end end end
Version data entries
20 entries across 20 versions & 1 rubygems