def for connection, open_timeout
http_args = []
http_args << connection.host
http_args << connection.port
if connection.proxy?
http_args << connection.proxy_address
http_args << connection.proxy_port
http_args << connection.proxy_user
http_args << connection.proxy_password
end
http = Net::HTTP.new(*http_args)
http.open_timeout = open_timeout
if connection.ssl?
http.use_ssl = true
if connection.ssl_verify_peer?
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.ca_file = connection.ssl_ca_file if connection.ssl_ca_file
http.ca_path = connection.ssl_ca_path if connection.ssl_ca_path
else
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
else
http.use_ssl = false
end
http.start
Session.new(http, connection.key)
end