Module: Puppet::Network::HttpPool
- Defined in:
- lib/puppet/network/http_pool.rb
Overview
This module contains the factory methods that should be used for getting a Puppet::Network::HTTP::Connection instance. The pool may return a new connection or a persistent cached connection, depending on the underlying pool implementation in use.
Class Method Summary collapse
-
.connection(host, port, use_ssl: true, ssl_context: nil) ⇒ Puppet::Network::HTTP::Connection
Retrieve a connection for the given host and port.
- .http_client_class ⇒ Object
- .http_client_class=(klass) ⇒ Object
-
.http_instance(host, port, use_ssl = true, verify_peer = true) ⇒ Puppet::Network::HTTP::Connection
deprecated
Deprecated.
Use #http_connection instead.
-
.http_ssl_instance(host, port, verifier = Puppet::SSL::Validator.default_validator()) ⇒ Puppet::Network::HTTP::Connection
deprecated
Deprecated.
Use #http_connection instead.
Class Method Details
.connection(host, port, use_ssl: true, ssl_context: nil) ⇒ Puppet::Network::HTTP::Connection
Retrieve a connection for the given host and port.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/puppet/network/http_pool.rb', line 77 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 |
.http_client_class ⇒ Object
18 19 20 |
# File 'lib/puppet/network/http_pool.rb', line 18 def self.http_client_class @http_client_class end |
.http_client_class=(klass) ⇒ Object
21 22 23 |
# File 'lib/puppet/network/http_pool.rb', line 21 def self.http_client_class=(klass) @http_client_class = klass end |
.http_instance(host, port, use_ssl = true, verify_peer = true) ⇒ Puppet::Network::HTTP::Connection
Deprecated.
Use #http_connection instead.
Retrieve a connection for the given host and port.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/puppet/network/http_pool.rb', line 36 def self.http_instance(host, port, use_ssl = true, verify_peer = true) verifier = if verify_peer Puppet::SSL::Validator.default_validator() else Puppet::SSL::Validator.no_validator() end http_client_class.new(host, port, :use_ssl => use_ssl, :verify => verifier) end |
.http_ssl_instance(host, port, verifier = Puppet::SSL::Validator.default_validator()) ⇒ Puppet::Network::HTTP::Connection
Deprecated.
Use #http_connection instead.
Get an http connection that will be secured with SSL and have the connection verified with the given verifier
60 61 62 63 64 |
# File 'lib/puppet/network/http_pool.rb', line 60 def self.http_ssl_instance(host, port, verifier = Puppet::SSL::Validator.default_validator()) http_client_class.new(host, port, :use_ssl => true, :verify => verifier) end |