Class: Puppet::HTTP::Factory Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/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

KEEP_ALIVE_TIMEOUT =

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

2**31 - 1
@@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.



18
19
20
21
22
23
24
# File 'lib/puppet/http/factory.rb', line 18

def initialize
  # PUP-1411, make sure that openssl is initialized before we try to connect
  unless @@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.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/puppet/http/factory.rb', line 26

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

  http = Puppet::HTTP::Proxy.proxy(URI(site.addr))
  http.use_ssl = site.use_ssl?
  if site.use_ssl?
    http.min_version = OpenSSL::SSL::TLS1_VERSION if http.respond_to?(:min_version)
    http.ciphers = Puppet[:ciphers]
  end
  http.read_timeout = Puppet[:http_read_timeout]
  http.open_timeout = Puppet[:http_connect_timeout]
  http.keep_alive_timeout = KEEP_ALIVE_TIMEOUT if http.respond_to?(:keep_alive_timeout=)

  # 0 means make one request and never retry
  http.max_retries = 0

  if Puppet[:sourceaddress]
    Puppet.debug("Using source IP #{Puppet[:sourceaddress]}")
    http.local_host = Puppet[:sourceaddress]
  end

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

  http
end