Method: Puppet::Network::HttpPool.connection
- Defined in:
- lib/puppet/network/http_pool.rb
.connection(host, port, use_ssl: true, ssl_context: nil) ⇒ Puppet::Network::HTTP::Connection
Retrieve a connection for the given host and port.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/puppet/network/http_pool.rb', line 75 def self.connection(host, port, use_ssl: true, ssl_context: nil) if use_ssl unless ssl_context # TRANSLATORS 'ssl_context' is an argument and should not be translated raise ArgumentError, _("An ssl_context is required when connecting to 'https://%{host}:%{port}'") % { host: host, port: port } end verifier = Puppet::SSL::Verifier.new(host, ssl_context) http_client_class.new(host, port, use_ssl: true, verifier: verifier) else if ssl_context # TRANSLATORS 'ssl_context' is an argument and should not be translated Puppet.warning(_("An ssl_context is unnecessary when connecting to 'http://%{host}:%{port}' and will be ignored") % { host: host, port: port }) end http_client_class.new(host, port, use_ssl: false) end end |