Class: Puppet::Network::HTTP::Factory Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/network/http/factory.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Factory for Net::HTTP objects.

Encapsulates the logic for creating a Net::HTTP object based on the specified Site and puppet settings.

Constant Summary collapse

@@openssl_initialized =

This classvariable is part of a private API. You should avoid using this classvariable if possible, as it may be removed or be changed in the future.

false

Instance Method Summary collapse

Constructor Details

#initializeFactory

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Factory.



14
15
16
17
18
19
20
# File 'lib/puppet/network/http/factory.rb', line 14

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

Instance Method Details

#create_connection(site) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/puppet/network/http/factory.rb', line 22

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