Sha256: 02f1b99c208a67109dc40f2de9409a68ca1e98a32adcb984ede230d5189bbbfa

Contents?: true

Size: 1.14 KB

Versions: 179

Compression:

Stored size: 1.14 KB

Contents

require 'openssl'
require 'net/http'
require 'puppet/util/http_proxy'

# 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]

    unless Puppet::Util::HttpProxy.no_proxy?(site)
      if Puppet[:http_proxy_host] == "none"
        args << nil << nil
      else
        args << Puppet[:http_proxy_host] << Puppet[:http_proxy_port]
      end
    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

179 entries across 179 versions & 3 rubygems

Version Path
puppet-retrospec-1.8.0 vendor/pup410/lib/puppet/network/http/factory.rb
puppet-retrospec-1.7.0 vendor/pup410/lib/puppet/network/http/factory.rb
puppet-retrospec-1.6.1 vendor/pup410/lib/puppet/network/http/factory.rb
bolt-0.10.0 vendored/puppet/lib/puppet/network/http/factory.rb
puppet-retrospec-1.6.0 vendor/pup410/lib/puppet/network/http/factory.rb
bolt-0.9.0 vendored/puppet/lib/puppet/network/http/factory.rb
bolt-0.8.0 vendored/puppet/lib/puppet/network/http/factory.rb
puppet-4.10.9 lib/puppet/network/http/factory.rb
puppet-4.10.9-x86-mingw32 lib/puppet/network/http/factory.rb
puppet-4.10.9-x64-mingw32 lib/puppet/network/http/factory.rb
puppet-4.10.9-universal-darwin lib/puppet/network/http/factory.rb
puppet-5.3.3 lib/puppet/network/http/factory.rb
puppet-5.3.3-x86-mingw32 lib/puppet/network/http/factory.rb
puppet-5.3.3-x64-mingw32 lib/puppet/network/http/factory.rb
puppet-5.3.3-universal-darwin lib/puppet/network/http/factory.rb
bolt-0.7.0 vendored/puppet/lib/puppet/network/http/factory.rb
bolt-0.6.1 vendored/puppet/lib/puppet/network/http/factory.rb
bolt-0.6.0 vendored/puppet/lib/puppet/network/http/factory.rb
puppet-retrospec-1.5.0 vendor/gems/puppet-4.5.2/lib/puppet/network/http/factory.rb
bolt-0.5.1 vendored/puppet/lib/puppet/network/http/factory.rb