summaryrefslogtreecommitdiff
path: root/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb
blob: 8b9ab5cc785b77d0044e4650abc3fcff05db139f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
##
# A Gem::Net::HTTP connection wrapper that holds extra information for managing the
# connection's lifetime.

class Gem::Net::HTTP::Persistent::Connection # :nodoc:

  attr_accessor :http

  attr_accessor :last_use

  attr_accessor :requests

  attr_accessor :ssl_generation

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

    reset
  end

  def finish
    @http.finish
  rescue IOError
  ensure
    reset
  end
  alias_method :close, :finish

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

  def ressl ssl_generation
    @ssl_generation = ssl_generation

    finish
  end

end