new(name = nil, proxy = nil)
public
Creates a new Bundler::Persistent::Net::HTTP::Persistent.
Set name to keep your connections apart
from everybody else’s. Not required currently, but highly recommended.
Your library name should be good enough. This parameter will be required
in a future version.
proxy may be set to a URI::HTTP or
:ENV to pick up proxy options from the environment.
See proxy_from_env
for details.
In order to use a URI for the proxy you may need to
do some extra work beyond URI parsing if the proxy
requires a password:
proxy = URI 'http://proxy.example'
proxy.user = 'AzureDiamond'
proxy.password = 'hunter2'
Show source
def initialize name = nil, proxy = nil
@name = name
@debug_output = nil
@proxy_uri = nil
@no_proxy = []
@headers = {}
@override_headers = {}
@http_versions = {}
@keep_alive = 30
@open_timeout = nil
@read_timeout = nil
@idle_timeout = 5
@max_requests = nil
@socket_options = []
@socket_options << [Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1] if
Socket.const_defined? :TCP_NODELAY
key = ['net_http_persistent', name].compact
@generation_key = [key, 'generations' ].join('_').intern
@ssl_generation_key = [key, 'ssl_generations'].join('_').intern
@request_key = [key, 'requests' ].join('_').intern
@timeout_key = [key, 'timeouts' ].join('_').intern
@certificate = nil
@ca_file = nil
@private_key = nil
@ssl_version = nil
@verify_callback = nil
@verify_mode = nil
@cert_store = nil
@generation = 0
@ssl_generation = 0
if HAVE_OPENSSL then
@verify_mode = OpenSSL::SSL::VERIFY_PEER
@reuse_ssl_sessions = OpenSSL::SSL.const_defined? :Session
end
@retry_change_requests = false
@ruby_1 = RUBY_VERSION < '2'
@retried_on_ruby_2 = !@ruby_1
self.proxy = proxy if proxy
end