Sha256: 15140d98d1a4fdd9202f6076c092b8426993834e1ab3155909d83c451c0fe2ac

Contents?: true

Size: 1.07 KB

Versions: 50

Compression:

Stored size: 1.07 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?
    # Use configured timeout (#1176)
    http.read_timeout = Puppet[:configtimeout]
    http.open_timeout = Puppet[:configtimeout]

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

    http
  end
end

Version data entries

50 entries across 50 versions & 2 rubygems

Version Path
puppet-retrospec-0.12.2 vendor/gems/puppet-3.7.3/lib/puppet/network/http/factory.rb
puppet-3.8.7 lib/puppet/network/http/factory.rb
puppet-3.8.7-x86-mingw32 lib/puppet/network/http/factory.rb
puppet-3.8.7-x64-mingw32 lib/puppet/network/http/factory.rb
puppet-3.8.6 lib/puppet/network/http/factory.rb
puppet-3.8.6-x86-mingw32 lib/puppet/network/http/factory.rb
puppet-retrospec-0.12.1 vendor/gems/puppet-3.7.3/lib/puppet/network/http/factory.rb
puppet-3.8.6-x64-mingw32 lib/puppet/network/http/factory.rb
puppet-retrospec-0.12.0 vendor/gems/puppet-3.7.3/lib/puppet/network/http/factory.rb
puppet-3.8.5 lib/puppet/network/http/factory.rb
puppet-3.8.5-x86-mingw32 lib/puppet/network/http/factory.rb
puppet-3.8.5-x64-mingw32 lib/puppet/network/http/factory.rb
puppet-3.8.4 lib/puppet/network/http/factory.rb
puppet-3.8.4-x86-mingw32 lib/puppet/network/http/factory.rb
puppet-3.8.4-x64-mingw32 lib/puppet/network/http/factory.rb
puppet-retrospec-0.11.0 vendor/gems/puppet-3.7.3/lib/puppet/network/http/factory.rb
puppet-retrospec-0.10.0 vendor/gems/puppet-3.7.3/lib/puppet/network/http/factory.rb
puppet-retrospec-0.9.1 vendor/gems/puppet-3.7.3/lib/puppet/network/http/factory.rb
puppet-retrospec-0.9.0 vendor/gems/puppet-3.7.3/lib/puppet/network/http/factory.rb
puppet-retrospec-0.8.1 vendor/gems/puppet-3.7.3/lib/puppet/network/http/factory.rb