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

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

Overview

A 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/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/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/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/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/net/http/persistent/connection.rb', line 13

def ssl_generation
  @ssl_generation
end

Instance Method Details

#finishObject



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

def finish
  @http.finish
rescue IOError
ensure
  reset
end

#resetObject



29
30
31
32
# File 'lib/net/http/persistent/connection.rb', line 29

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

#ressl(ssl_generation) ⇒ Object



34
35
36
37
38
# File 'lib/net/http/persistent/connection.rb', line 34

def ressl ssl_generation
  @ssl_generation = ssl_generation

  finish
end