module Puppet::Network::HttpPool

This module is deprecated.

@api public @deprecated Use {Puppet::HTTP::Client} instead.

Public Class Methods

connection(host, port, use_ssl: true, ssl_context: nil) click to toggle source

Retrieve a connection for the given host and port.

@param host [String] The host to connect to @param port [Integer] The port to connect to @param use_ssl [Boolean] Whether to use SSL, defaults to `true`. @param ssl_context [Puppet::SSL:SSLContext, nil] The ssl context to use

when making HTTPS connections. Required when `use_ssl` is `true`.

@return [Puppet::Network::HTTP::Connection]

@deprecated Use {Puppet.runtime} instead. @api public

   # File lib/puppet/network/http_pool.rb
57 def self.connection(host, port, use_ssl: true, ssl_context: nil)
58   Puppet.warn_once('deprecations', self, "The method 'Puppet::Network::HttpPool.connection' is deprecated. Use Puppet.runtime[:http] instead")
59 
60   if use_ssl
61     unless ssl_context
62       # TRANSLATORS 'ssl_context' is an argument and should not be translated
63       raise ArgumentError, _("An ssl_context is required when connecting to 'https://%{host}:%{port}'") % { host: host, port: port }
64     end
65 
66     verifier = Puppet::SSL::Verifier.new(host, ssl_context)
67     http_client_class.new(host, port, use_ssl: true, verifier: verifier)
68   else
69     if ssl_context
70       # TRANSLATORS 'ssl_context' is an argument and should not be translated
71       Puppet.warning(_("An ssl_context is unnecessary when connecting to 'http://%{host}:%{port}' and will be ignored") % { host: host, port: port })
72     end
73 
74     http_client_class.new(host, port, use_ssl: false)
75   end
76 end
http_client_class() click to toggle source
   # File lib/puppet/network/http_pool.rb
14 def self.http_client_class
15   @http_client_class
16 end
http_client_class=(klass) click to toggle source
   # File lib/puppet/network/http_pool.rb
17 def self.http_client_class=(klass)
18   @http_client_class = klass
19 end
http_instance(host, port, use_ssl = true, verify_peer = true) click to toggle source

Retrieve a connection for the given host and port.

@param host [String] The hostname to connect to @param port [Integer] The port on the host to connect to @param use_ssl [Boolean] Whether to use an SSL connection @param verify_peer [Boolean] Whether to verify the peer credentials, if possible. Verification will not take place if the CA certificate is missing. @return [Puppet::Network::HTTP::Connection]

@deprecated Use {Puppet.runtime} instead. @api public

   # File lib/puppet/network/http_pool.rb
32 def self.http_instance(host, port, use_ssl = true, verify_peer = true)
33   Puppet.warn_once('deprecations', self, "The method 'Puppet::Network::HttpPool.http_instance' is deprecated. Use Puppet.runtime[:http] instead")
34 
35   if verify_peer
36     verifier = Puppet::SSL::Verifier.new(host, nil)
37     http_client_class.new(host, port, use_ssl: use_ssl, verifier: verifier)
38   else
39     ssl = Puppet::SSL::SSLProvider.new
40     verifier = Puppet::SSL::Verifier.new(host, ssl.create_insecure_context)
41     http_client_class.new(host, port, use_ssl: use_ssl, verifier: verifier)
42   end
43 end