Module: Wrest::Native::ConnectionFactory

Defined in:
lib/wrest/native/connection_factory.rb

Instance Method Summary collapse

Instance Method Details

#create_connection(options = { timeout: 60, verify_mode: OpenSSL::SSL::VERIFY_NONE }) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/wrest/native/connection_factory.rb', line 15

def create_connection(options = { timeout: 60, verify_mode: OpenSSL::SSL::VERIFY_NONE })
  options[:timeout] ||= 60
  connection = Net::HTTP.new(host, port)
  connection.read_timeout = options[:timeout]
  if https?
    connection.use_ssl     = true
    connection.verify_mode = options[:verify_mode] || OpenSSL::SSL::VERIFY_PEER
    connection.ca_path = options[:ca_path] if options[:ca_path]
  end
  connection
end