Class: Gem::Net::HTTP::Persistent::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb

Overview

A Gem::Net::HTTP connection wrapper that holds extra information for managing the connection’s lifetime.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_class, http_args, ssl_generation) ⇒ Connection

Returns a new instance of Connection.



15
16
17
18
19
20
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb', line 15

def initialize http_class, http_args, ssl_generation
  @http           = http_class.new(*http_args)
  @ssl_generation = ssl_generation

  reset
end

Instance Attribute Details

#httpObject

:nodoc:



7
8
9
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb', line 7

def http
  @http
end

#last_useObject

Returns the value of attribute last_use.



9
10
11
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb', line 9

def last_use
  @last_use
end

#requestsObject

Returns the value of attribute requests.



11
12
13
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb', line 11

def requests
  @requests
end

#ssl_generationObject

Returns the value of attribute ssl_generation.



13
14
15
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb', line 13

def ssl_generation
  @ssl_generation
end

Instance Method Details

#finishObject Also known as: close



22
23
24
25
26
27
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb', line 22

def finish
  @http.finish
rescue IOError
ensure
  reset
end

#resetObject



30
31
32
33
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb', line 30

def reset
  @last_use = Gem::Net::HTTP::Persistent::EPOCH
  @requests = 0
end

#ressl(ssl_generation) ⇒ Object



35
36
37
38
39
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb', line 35

def ressl ssl_generation
  @ssl_generation = ssl_generation

  finish
end