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



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/wrest/native/connection_factory.rb', line 12

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