net-http-persistent 1.3 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 1.3.1 / 2010-09-13
2
+
3
+ * Bug Fixes
4
+ * #connection_for no longer tries to ssl-enable an existing connection.
5
+ Patch by Joseph West.
6
+
1
7
  === 1.3 / 2010-09-08
2
8
 
3
9
  * Minor Enhancements
@@ -37,7 +37,7 @@ class Net::HTTP::Persistent
37
37
  ##
38
38
  # The version of Net::HTTP::Persistent use are using
39
39
 
40
- VERSION = '1.3'
40
+ VERSION = '1.3.1'
41
41
 
42
42
  ##
43
43
  # Error class for errors raised by Net::HTTP::Persistent. Various
@@ -198,6 +198,8 @@ class Net::HTTP::Persistent
198
198
 
199
199
  def connection_for uri
200
200
  Thread.current[@connection_key] ||= {}
201
+ Thread.current[@request_key] ||= Hash.new 0
202
+
201
203
  connections = Thread.current[@connection_key]
202
204
 
203
205
  net_http_args = [uri.host, uri.port]
@@ -208,16 +210,17 @@ class Net::HTTP::Persistent
208
210
  net_http_args.concat @proxy_args
209
211
  end
210
212
 
211
- connections[connection_id] ||= Net::HTTP.new(*net_http_args)
212
- connection = connections[connection_id]
213
+ unless connection = connections[connection_id] then
214
+ connections[connection_id] = Net::HTTP.new(*net_http_args)
215
+ connection = connections[connection_id]
216
+ ssl connection if uri.scheme == 'https'
217
+ end
213
218
 
214
219
  unless connection.started? then
215
220
  connection.set_debug_output @debug_output if @debug_output
216
221
  connection.open_timeout = @open_timeout if @open_timeout
217
222
  connection.read_timeout = @read_timeout if @read_timeout
218
223
 
219
- ssl connection if uri.scheme == 'https'
220
-
221
224
  connection.start
222
225
  end
223
226
 
@@ -336,7 +339,6 @@ class Net::HTTP::Persistent
336
339
  # it will be retried automatically.
337
340
 
338
341
  def request uri, req = nil, &block
339
- Thread.current[@request_key] ||= Hash.new 0
340
342
  retried = false
341
343
  bad_response = false
342
344
 
@@ -7,6 +7,18 @@ class Net::HTTP
7
7
  alias orig_connect connect
8
8
 
9
9
  def connect
10
+ return unless use_ssl?
11
+
12
+ io = open '/dev/null'
13
+
14
+ @ssl_context ||= OpenSSL::SSL::SSLContext.new
15
+
16
+ @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER unless
17
+ @ssl_context.verify_mode
18
+
19
+ s = OpenSSL::SSL::SSLSocket.new io, @ssl_context
20
+
21
+ @socket = Net::BufferedIO.new s
10
22
  end
11
23
  end
12
24
 
@@ -136,6 +148,22 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
136
148
  assert_same c, conns['example.com:80']
137
149
  end
138
150
 
151
+ def test_connection_for_finished_ssl
152
+ uri = URI.parse 'https://example.com/path'
153
+ c = @http.connection_for uri
154
+
155
+ assert c.started?
156
+ assert c.use_ssl?
157
+
158
+ @http.finish c
159
+
160
+ refute c.started?
161
+
162
+ c2 = @http.connection_for uri
163
+
164
+ assert c2.started?
165
+ end
166
+
139
167
  def test_connection_for_host_down
140
168
  cached = Object.new
141
169
  def cached.address; 'example.com' end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-http-persistent
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- version: "1.3"
9
+ - 1
10
+ version: 1.3.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Eric Hodel
@@ -35,7 +36,7 @@ cert_chain:
35
36
  x52qPcexcYZR7w==
36
37
  -----END CERTIFICATE-----
37
38
 
38
- date: 2010-09-08 00:00:00 -07:00
39
+ date: 2010-09-13 00:00:00 -07:00
39
40
  default_executable:
40
41
  dependencies:
41
42
  - !ruby/object:Gem::Dependency
metadata.gz.sig CHANGED
Binary file