net-http-persistent 1.4 → 1.4.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.4.1 / 2010-10-13
2
+
3
+ * Bug Fixes
4
+ * Don't finish the connection when we're retrying, reset it. Patch by James
5
+ Tucker.
6
+
1
7
  === 1.4 / 2010-09-29
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.4'
40
+ VERSION = '1.4.1'
41
41
 
42
42
  ##
43
43
  # Error class for errors raised by Net::HTTP::Persistent. Various
@@ -370,13 +370,17 @@ class Net::HTTP::Persistent
370
370
  retry
371
371
  rescue IOError, EOFError, Timeout::Error,
372
372
  Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE => e
373
- due_to = "(due to #{e.message} - #{e.class})"
374
- message = error_message connection
375
373
 
376
- finish connection
374
+ if retried or not idempotent? req
375
+ due_to = "(due to #{e.message} - #{e.class})"
376
+ message = error_message connection
377
+
378
+ finish connection
379
+
380
+ raise Error, "too many connection resets #{due_to} #{message}"
381
+ end
377
382
 
378
- raise Error, "too many connection resets #{due_to} #{message}" if
379
- retried or not idempotent? req
383
+ reset connection
380
384
 
381
385
  retried = true
382
386
  retry
@@ -42,21 +42,32 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
42
42
  end
43
43
  end
44
44
 
45
- def basic_connection
46
- c = Object.new
47
- c.instance_variable_set :@finished, false
48
- c.instance_variable_set :@reset, false
49
- c.instance_variable_set :@started, false
50
-
51
- def c.finish; @finished = true end
52
- def c.reset; @reset = true end
53
- def c.start; end
54
-
55
- def c.req() @req; end
56
- def c.reset?; @reset end
57
- def c.started?; true end
58
- def c.finished?; @finished end
45
+ class BasicConnection
46
+ attr_accessor :started, :finished, :address, :port
47
+ attr_reader :req
48
+ def initialize
49
+ @started, @finished = 0, 0
50
+ @address, @port = 'example.com', 80
51
+ end
52
+ def finish
53
+ @finished += 1
54
+ end
55
+ def start
56
+ @started += 1
57
+ end
58
+ def reset?
59
+ @started == @finished + 1
60
+ end
61
+ def started?
62
+ @started >= 1
63
+ end
64
+ def finished?
65
+ @finished >= 1
66
+ end
67
+ end
59
68
 
69
+ def basic_connection
70
+ c = BasicConnection.new
60
71
  conns["#{@uri.host}:#{@uri.port}"] = c
61
72
  c
62
73
  end
@@ -124,8 +135,8 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
124
135
  end
125
136
 
126
137
  def test_connection_for_cached
127
- cached = Object.new
128
- def cached.started?; true end
138
+ cached = basic_connection
139
+ cached.start
129
140
  conns['example.com:80'] = cached
130
141
 
131
142
  c = @http.connection_for @uri
@@ -165,9 +176,7 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
165
176
  end
166
177
 
167
178
  def test_connection_for_host_down
168
- cached = Object.new
169
- def cached.address; 'example.com' end
170
- def cached.port; 80 end
179
+ cached = basic_connection
171
180
  def cached.start; raise Errno::EHOSTDOWN end
172
181
  def cached.started?; false end
173
182
  conns['example.com:80'] = cached
@@ -208,9 +217,7 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
208
217
  end
209
218
 
210
219
  def test_connection_for_refused
211
- cached = Object.new
212
- def cached.address; 'example.com' end
213
- def cached.port; 80 end
220
+ cached = basic_connection
214
221
  def cached.start; raise Errno::ECONNREFUSED end
215
222
  def cached.started?; false end
216
223
  conns['example.com:80'] = cached
@@ -223,7 +230,7 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
223
230
  end
224
231
 
225
232
  def test_error_message
226
- c = Object.new
233
+ c = basic_connection
227
234
  reqs[c.object_id] = 5
228
235
 
229
236
  assert_equal "after 5 requests on #{c.object_id}", @http.error_message(c)
@@ -236,12 +243,7 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
236
243
  end
237
244
 
238
245
  def test_finish
239
- c = Object.new
240
- c.instance_variable_set :@started, false
241
- def c.finish; @finished = true end
242
- def c.finished?; @finished end
243
- def c.start; @started = true end
244
- def c.started?; @started end
246
+ c = basic_connection
245
247
  reqs[c.object_id] = 5
246
248
 
247
249
  @http.finish c
@@ -252,12 +254,8 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
252
254
  end
253
255
 
254
256
  def test_finish_io_error
255
- c = Object.new
256
- c.instance_variable_set :@started, false
257
- def c.finish; @finished = true; raise IOError end
258
- def c.finished?; @finished end
259
- def c.start; @started = true end
260
- def c.started?; @started end
257
+ c = basic_connection
258
+ def c.finish; @finished += 1; raise IOError end
261
259
  reqs[c.object_id] = 5
262
260
 
263
261
  @http.finish c
@@ -334,26 +332,20 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
334
332
  end
335
333
 
336
334
  def test_reset
337
- c = Object.new
338
- def c.finish; @finished = true end
339
- def c.finished?; @finished end
340
- def c.start; @started = true end
341
- def c.started?; @started end
335
+ c = basic_connection
336
+ c.start
342
337
  reqs[c.object_id] = 5
343
338
 
344
339
  @http.reset c
345
340
 
346
341
  assert c.started?
347
342
  assert c.finished?
343
+ assert c.reset?
348
344
  assert_nil reqs[c.object_id]
349
345
  end
350
346
 
351
347
  def test_reset_io_error
352
- c = Object.new
353
- def c.finish; @finished = true; raise IOError end
354
- def c.finished?; @finished end
355
- def c.start; @started = true end
356
- def c.started?; @started end
348
+ c = basic_connection
357
349
  reqs[c.object_id] = 5
358
350
 
359
351
  @http.reset c
@@ -363,10 +355,7 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
363
355
  end
364
356
 
365
357
  def test_reset_host_down
366
- c = Object.new
367
- def c.address; 'example.com' end
368
- def c.finish; end
369
- def c.port; 80 end
358
+ c = basic_connection
370
359
  def c.start; raise Errno::EHOSTDOWN end
371
360
  reqs[c.object_id] = 5
372
361
 
@@ -378,10 +367,7 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
378
367
  end
379
368
 
380
369
  def test_reset_refused
381
- c = Object.new
382
- def c.address; 'example.com' end
383
- def c.finish; end
384
- def c.port; 80 end
370
+ c = basic_connection
385
371
  def c.start; raise Errno::ECONNREFUSED end
386
372
  reqs[c.object_id] = 5
387
373
 
@@ -505,6 +491,7 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
505
491
 
506
492
  @http.request @uri
507
493
 
494
+ assert c.reset?
508
495
  assert c.finished?
509
496
  end
510
497
 
@@ -557,7 +544,7 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
557
544
  end
558
545
 
559
546
  def test_shutdown_not_started
560
- c = Object.new
547
+ c = basic_connection
561
548
  def c.finish() raise IOError end
562
549
 
563
550
  conns["#{@uri.host}:#{@uri.port}"] = c
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: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- version: "1.4"
9
+ - 1
10
+ version: 1.4.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-30 00:00:00 -07:00
39
+ date: 2010-10-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