Sha256: b01e53150dbabffb71478e41e703a3da1ca49710921ada34364da2b27f5578bd

Contents?: true

Size: 1.04 KB

Versions: 9

Compression:

Stored size: 1.04 KB

Contents

require 'openssl'
require 'net/http'

# Factory for <tt>Net::HTTP</tt> objects.
#
# Encapsulates the logic for creating a <tt>Net::HTTP</tt> object based on the
# specified {Puppet::Network::HTTP::Site Site} and puppet settings.
#
# @api private
#
class Puppet::Network::HTTP::Factory
  @@openssl_initialized = false

  def initialize
    # PUP-1411, make sure that openssl is initialized before we try to connect
    if ! @@openssl_initialized
      OpenSSL::SSL::SSLContext.new
      @@openssl_initialized = true
    end
  end

  def create_connection(site)
    Puppet.debug("Creating new connection for #{site}")

    args = [site.host, site.port]
    if Puppet[:http_proxy_host] == "none"
      args << nil << nil
    else
      args << Puppet[:http_proxy_host] << Puppet[:http_proxy_port]
    end

    http = Net::HTTP.new(*args)
    http.use_ssl = site.use_ssl?
    http.read_timeout = Puppet[:http_read_timeout]
    http.open_timeout = Puppet[:http_connect_timeout]

    if Puppet[:http_debug]
      http.set_debug_output($stderr)
    end

    http
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
puppet-4.1.0 lib/puppet/network/http/factory.rb
puppet-4.1.0-x86-mingw32 lib/puppet/network/http/factory.rb
puppet-4.1.0-x64-mingw32 lib/puppet/network/http/factory.rb
puppet-4.0.0 lib/puppet/network/http/factory.rb
puppet-4.0.0-x86-mingw32 lib/puppet/network/http/factory.rb
puppet-4.0.0-x64-mingw32 lib/puppet/network/http/factory.rb
puppet-4.0.0.rc1 lib/puppet/network/http/factory.rb
puppet-4.0.0.rc1-x86-mingw32 lib/puppet/network/http/factory.rb
puppet-4.0.0.rc1-x64-mingw32 lib/puppet/network/http/factory.rb