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 name “HttpPool” is a misnomer, and a leftover of history, but we would like to make this cache connections in the future.

Class Method Summary collapse

Class Method Details

.http_instance(host, port, use_ssl = true, verify_peer = true) ⇒ Puppet::Network::HTTP::Connection

Retrieve a connection for the given host and port.

Parameters:

  • host (String)

    The hostname to connect to

  • port (Integer)

    The port on the host to connect to

  • use_ssl (Boolean) (defaults to: true)

    Whether to use an SSL connection

  • verify_peer (Boolean) (defaults to: true)

    Whether to verify the peer credentials, if possible. Verification will not take place if the CA certificate is missing.

Returns:



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/puppet/network/http_pool.rb', line 25

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

  Puppet::Network::HTTP::Connection.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

Get an http connection that will be secured with SSL and have the connection verified with the given verifier

Parameters:

  • host (String)

    the DNS name to connect to

  • port (Integer)

    the port to connect to

  • verifier (#setup_connection, #peer_certs, #verify_errors) (defaults to: Puppet::SSL::Validator.default_validator())

    An object that will setup the appropriate verification on a Net::HTTP instance and report any errors and the certificates used.

Returns:



48
49
50
51
52
# File 'lib/puppet/network/http_pool.rb', line 48

def self.http_ssl_instance(host, port, verifier = Puppet::SSL::Validator.default_validator())
  Puppet::Network::HTTP::Connection.new(host, port,
                                        :use_ssl => true,
                                        :verify => verifier)
end