123456789_123456789_123456789_123456789_123456789_

Class: Capybara::Server::Checker Private

Relationships & Source Files
Inherits: Object
Defined in: lib/capybara/server/checker.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(host, port) ⇒ Checker

[ GitHub ]

  
# File 'lib/capybara/server/checker.rb', line 8

def initialize(host, port)
  @host, @port = host, port
  @ssl = false
end

Instance Attribute Details

#ssl?Boolean (readonly)

[ GitHub ]

  
# File 'lib/capybara/server/checker.rb', line 21

def ssl?
  @ssl
end

Instance Method Details

#http_request(&block) (private)

[ GitHub ]

  
# File 'lib/capybara/server/checker.rb', line 27

def http_request(&block)
  make_request(read_timeout: 2, &block)
end

#https_request(&block) (private)

[ GitHub ]

  
# File 'lib/capybara/server/checker.rb', line 31

def https_request(&block)
  make_request(**ssl_options, &block)
end

#make_request(**options, &block) (private)

[ GitHub ]

  
# File 'lib/capybara/server/checker.rb', line 35

def make_request(**options, &block)
  Net::HTTP.start(@host, @port, options.merge(max_retries: 0), &block)
end

#request(&block)

[ GitHub ]

  
# File 'lib/capybara/server/checker.rb', line 13

def request(&block)
  ssl? ? https_request(&block) : http_request(&block)
rescue *TRY_HTTPS_ERRORS
  res = https_request(&block)
  @ssl = true
  res
end

#ssl_options (private)

[ GitHub ]

  
# File 'lib/capybara/server/checker.rb', line 39

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