Sha256: c18614debab7de29f612ad0bcfae264c602fe7b9a031c9f033b5925f09cb8501

Contents?: true

Size: 759 Bytes

Versions: 12

Compression:

Stored size: 759 Bytes

Contents

# frozen_string_literal: true

module Capybara
  class Server
    class Checker
      def initialize(host, port)
        @host, @port = host, port
        @ssl = false
      end

      def request(&block)
        ssl? ? https_request(&block) : http_request(&block)
      rescue EOFError, Net::ReadTimeout
        res = https_request(&block)
        @ssl = true
        res
      end

      def ssl?
        @ssl
      end

    private

      def http_request(&block)
        Net::HTTP.start(@host, @port, read_timeout: 2, &block)
      end

      def https_request(&block)
        Net::HTTP.start(@host, @port, ssl_options, &block)
      end

      def ssl_options
        { use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE }
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
tdiary-5.0.11 vendor/bundle/gems/capybara-3.6.0/lib/capybara/server/checker.rb
capybara-3.7.2 lib/capybara/server/checker.rb
capybara-3.7.1 lib/capybara/server/checker.rb
capybara-3.7.0 lib/capybara/server/checker.rb
capybara-3.6.0 lib/capybara/server/checker.rb
capybara-3.5.1 lib/capybara/server/checker.rb
capybara-3.5.0 lib/capybara/server/checker.rb
capybara-3.4.2 lib/capybara/server/checker.rb
capybara-3.4.1 lib/capybara/server/checker.rb
capybara-3.4.0 lib/capybara/server/checker.rb
capybara-3.3.1 lib/capybara/server/checker.rb
capybara-3.3.0 lib/capybara/server/checker.rb